003--struts2 Advanced

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.