Struts2 Advanced
1, common type of result
1.1. JSP response
Dispatcher: Invoking JSP responses in Request forwarding mode
Redirect: Invoking a JSP response in a request redirection manner
1.2. Action response
Redirectaction: Invokes an action with a request redirection method
Chain: Invokes an action in Request forwarding mode
1.3. Stream response
Stream: Action one of the InputStream properties for client output
1.4. JSON response
JSON: You can export the Action property in JSON format
2. Interceptor
Interceptor Encapsulation Features: versatility, can be reused multiple times.
The Struts framework provides a number of built-in interceptors that developers can customize.
1) Understanding the specification of interceptor components
The Interceptor Component implementation class must implement the Interceptor interface to implement the Interceptor method
2) Declaration Configuration for Interceptor Components
<package>
<interceptors>
<!--declaring an interceptor--
<interceptor name= "name" class= "Implementation Class" >
<!--declaring an interceptor stack--
<interceptor-stack name= "Interceptor stack name" >
<interceptor-ref name= "Interceptor 1"/>
<interceptor-ref name= "Interceptor 2"/>
</interceptor-stack>
</interceptors>
</package>
3) Use of interceptor components
A. Displaying references for action
<action name= "" class= "" >
<interceptor-ref name= "Interceptor name or stack name"/>
<result></result>
</action>
B. Set a default reference for action, (call default if no interceptor is specified for action)
If the <package> element inherits Struts-default, the default call Defaultstack <default-interceptor-ref name= "Defaultstack"/>
Note: Defaultstack is performed without an interceptor specified by the <action> element,
003--struts2 Advanced