是否可以在jsp scriptlet中访问struts2变量? [英] Is it possible to access struts2 variable in jsp scriptlet?
本文介绍了是否可以在jsp scriptlet中访问struts2变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在jsp scriptlet中访问struts2变量?
Is it possible to access struts2 variable in jsp scriptlet?
如果我有struts2变量,如
If I have struts2 variable like
<s:set var="test" value="%{'true'}"/>
我可以在JSP scriptlet中使用变量"test"吗?
Can I use variable "test" in JSP scriptlet?
如果是.怎么可能?
任何人都可以提出一些想法吗?
Can anyone give some idea about it?
谢谢.
推荐答案
<jsp:useBean id="test" class="java.lang.String" scope="request"/>
<%
test = "false";
%>
1. outside scriptlet: <c:out value="${test}"/> <!-- will not print anything -->
<%
out.println("2. in scriptlet: " + test); // will print false
%>
<c:set var="test" value="true" />
3. outside scriptlet: <c:out value="${test}"/> <!-- will print true -->
<%
out.println("4. in scriptlet: " + test); // will print false
%>
这篇关于是否可以在jsp scriptlet中访问struts2变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文