Struts2:JSP中獲取Application,Session和Request范圍的值[筆記]
The application, session and request objects are available from within s tags in jsp wherever ognl can be evaluated. Use the #application, #session, or #request syntax to get the object and access values by their keys using ['key'].
任何ognl能被計算的值,在jsp中用s標簽都可以獲得application,session和request對象。
Accessing scoped variables via <s:property.../> tags
<s:property value="#application\['foo'\]"/>
<s:property value="#session\['baz'\]"/>
Conversely, if you would like to make Struts 2 objects available to a JSP/JSTL scope, the s:set tag may be used like this:
相反,如果你項是的Struts2對象能在JSP/JSTL范圍內獲得,s:set標簽可能這樣用:
Expose OGNL 'jobs' value to JSP/JSTL scope 'jobz'
把OGNL'jobs'值放入JSP/JSTL范圍命名'jobz'
把OGNL'jobs'值放入JSP/JSTL范圍命名'jobz'
<s:set name="jobz" value="jobs" scope="request" />
<c:forEach items="${jobz} var="job">
...
</c:forEach>
![]() |
"Auto-exposure" In Struts 2 OGNL values are automagically exposed to JSP/JSTL; using <s:set.../> as described above may not be necessary. 在Struts2 OGNL的值被自動暴露給JSP/JSTL;上面例子中<s:set .../>可能不需要。 |
疑問啊:Struts2 OGNL和OGNL難道是兩回事?
posted on 2007-04-29 09:59 MingIsMe 閱讀(4778) 評論(0) 編輯 收藏 所屬分類: Struts2學習