2013-06-19 19 views
1
// Template 
<%@ tag description="master" pageEncoding="UTF-8"%> 
<%@ attribute name="js" fragment="true" %> 
<!doctype html> 
<c:set var="myVar" value="1" /> 
<html> 
<head> 
    <jsp:invoke fragment="js" /> 
</head> 
<body> 
</html> 

// Page 
<%@ page pageEncoding="UTF-8"%> 
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %> 
<t:master> 
    <jsp:attribute name="js"> 
     <script type="text/javascript" src="/javascript/administration/customers.js"></script> 
    </jsp:attribute> 
</t:master> 

是否有可能从页面获取myVar?谢谢Jstl:从自定义标记中获取变量

解决方案1: 我可以声明变量为scope="request",所以我可以通过${requestScope.test}访问它。但这是好方法吗?

+0

你试过'$ {myVar}'吗? – sp00m

+0

是的,页面范围在这种情况下不起作用 – nKognito

回答

1

解决方法:使用scope =“request”声明变量,它将通过$ {requestScope.test}访问。

相关问题