一般的,在JSP页面中访问Servlet/JSP作用域对象,可以使用Java脚本或EL表达式,在Struts2中,还可以使用OGNL表达式访问包括Application scope attributes, Session scope attributes, Request scope attributes, Request parameters and framework Context scope parameters:
Application Scope Attribute
- <s:property value="%{#application.myApplicationAttribute}" />
Session Scope Attribute
- <s:property value="%{#session.mySessionAttribute}" />
Request Scope Attribute
- <s:property value="%{#request.myRequestAttribute}" />
Request Parameter
- <s:property value="%{#parameters.myParameter}" />
Context Scope Parameter
- <s:property value="%{#myContextParam}" />
最后一个没有对应的EL访问方式,上面每个语句中去掉百分号和大括号也是可以的。
本文介绍如何在Struts2框架中通过OGNL表达式访问不同作用域的对象,包括应用程序范围、会话范围、请求范围的属性以及请求参数和上下文参数。
1128

被折叠的 条评论
为什么被折叠?



