1. Tag使用的三个原则:
struts2/struts-2.0.11/docs/docs/tag-syntax.html
Boiled down, the tag attributes are evaluated using three rules.
- All String attribute types are parsed for the "%{ ... }" notation.
- All non-String attribute types are not parsed, but evaluated directly as an expression
- The exception to rule #2 is that if the non-String attribute uses the escape notion "{%{}", the notation is ignored as redundant, and the content evaluated.
2. JSP里面获取Servlet / JSP Scoped Objects
There are a couple of ways to obtain access to ValueStack from JSPs.
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}" />