The application framework based on MVC pattern struts (1)

Source: Internet
Author: User

1.struts Development Steps
    • The introduction of struts's jar package;
    • The core functions of struts are introduced in Web. XML, and the Struts core filter is configured.
    • Development action, generally inherited from Actionsupport, the business method must return a string type, the method cannot have parameters;
    • Configure the action in Src/struts.xml;
2.struts Execution Process

Server Startup

    • Load the project's web. xml;
    • Create a struts core filter object and execute its init () method, reading Struts-default.xml, Struts-plugin.xml, and struts.xml configuration files sequentially;

Access

    • The user accesses the action, and the server creates an action instance based on the access URL to find the corresponding action class;
    • Execute Struts Interceptor;
    • Each subsequent visit creates an instance of the action and then executes the interceptor;
3.struts-default.xml detailed
    • The bean node develops the node type that struts creates at run time;

    • Specifies the Struts-default package that the package in the user-written struts.xml must inherit from.

These include:

    • The result type of the jump

Dispathcer: Default Value

Redirect: redirect

Redirectaction: Redirect to Action resource

Stream: used when downloading files

    • 32 interceptors are defined, and for convenience of reference, the Interceptor can be referenced by means of a stack definition;
    • The default execution of interceptors (8), executed sequentially;
    • Action of the default value type;
4. Interceptor vs Filter

Interceptors and filters play a role in intercepting resources.

Filter:

Intercept all resources: JSP, servlet, CSS, JS and so on;

Can be used in all servlet projects;

Interceptors:

Only action requests can be intercepted;

Is the concept of struts and can only be used in struts projects;

The application framework based on MVC pattern struts (1)

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.