Web. xml

Source: Internet
Author: User

TheWeb. xmlWeb ApplicationDescriptor (description)File
Represents (Representative)The core of the Java Web application, so it is
Appropriate (appropriate)That it is also part of the core of the Struts framework. InWeb. xmlFile, struts
Defines)Its filterdispatcher, the servlet filter class that
Initializes (initialization)The Struts framework and
Handles)All requests. This filter can
Contain (inclusive)Initialization parameters that affect what, if any, additional configuration files are loaded and how the framework showould behave.

Web. xml describes the core of Java Web applications. Therefore, it is the core part of the Struts framework,

In this web. xml file, Struts defines its filterdispather. The servletfilter class initializes the Struts framework and processes all requests.

Fiter can set the initial parameters, how other configuration files are loaded and how the framework works.

In addition to the filterdispatcher, Struts also provides an actioncontextcleanup class that
Handles (processing) Special cleanupTasks)When other filters, such as those used by sitemesh, need access to an initialized Struts framework.

Added filterdispatcher. Struts also provides an actioncontextcleanup class, which can clearly process tasks,

For example, if sitemesh is used, you need to access an initialized Struts framework.

Key initialization parameters // initialization parameter value

  • Config-a comma-delimited list of xml configuration files to load. // an xml configuration file is loaded with a comma-separated list.

  • Actionpackages-a comma-delimited list of Java packages to scan for actions. // actions check for a Java package that is separated by commas (,).

  • Configproviders-a comma-delimited list of Java classes that implement the configurationprovider interface that shoshould be used for building the configuration. // a Java class is separated by commas (,) to implement the configurationprovider interface. It can be used to create configurations.

  • Loggerfactory-the Class Name of the loggerfactory implementation. // implementation of the loggerfactory class name.

  • *-Any other parameters are
    Treated)
    As framework constants. // any parameter is a constant of the framework.


Why the filter is mapped with/* and how to configure explicit exclusions (since 2.1.7)

Why does the filter use/* and how to specify other parameters for the configuration?

In the example above we 've mapped the struts 2 dispatcher/*,
So struts 2 hasCrack (open)At all incoming requests. This is because struts 2 serves staticContent)
From its jar files, including dojo JavaScript files (if using s2.0, or the dojo Plugin in s2.1 +) andFreemarker (custom tag)
Templates (standard)
For the struts 2 tags that
Produce (available)
HTML.

In this example, we always use the/* ing of struts2, so struts2 is to open all the request items.
This is because struts 2 provides static content from its package file,
Includes the dojo Jav file asv and custom tags to provide HTML for struts;

If we change the filter mapping to something else, for example/*. Html, We must take this inAccount (description)And
Extract (extract)The content that wowouldNormally (normal)
Be served from the struts 2 jar files, or some otherSolution).

If we change the filter ing and use another one, for example,/*. html,
We must add it to describe it, and extract the content from the struts 2 package file. Or other solutions

Since struts 2.1.7, you areAble (yes)To provideComma (comma)
Seperated)
List of patterns for which when matching against
Request URL the filter will just pass by. This is done via the configuration option struts. Action. excludepattern, for example in your struts. xml

Since struts 2.1.7, you can

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.