Web. XML Component Load Order

Source: Internet
Author: User

<Web-app><Display-name></Display-name>the name of the Web App<Description></Description>description of the web App<Context-param></Context-param>context-param Element declaration application-scoped initialization Parameters<!– Specify the spring configuration file location –><Context-param><Param-name>Contextconfiglocation</Param-name><Param-value><!– Load multiple Spring profiles –>/web-inf/applicationcontext.xml,/web-inf/action-servlet.xml</Param-value></Context-param><Filter></Filter>The filter relates a name to a class that implements the Javax.servlet.Filter interface<filter-mapping></filter-mapping>Once a filter is named, use the filter-mapping element to correlate it with one or more servlet or JSP pages<Listener></Listener>event listeners are notified when a session or servlet environment is established, modified, and deleted. The listener element indicates the event listener class. such as log4j this widely used monitoring and<!– Define spring Listener, load spring–><Listener><Listener-class>Org.springframework.web.context.ContextLoaderListener</Listener-class></Listener><servlet></servlet>when you set initialization parameters or custom URLs to a servlet or JSP page, you must first name the servlet or JSP page. The servlet element is used to accomplish this task. <servlet-mapping></servlet-mapping>the server typically provides a default url:http://host/webappprefix/servlet/servletname for the servlet. However, this URL is often changed so that the servlet can access the initialization parameters or make it easier to handle relative URLs. When changing the default URL, use the servlet-mapping element<Session-config></Session-config>If a session is not accessed for a certain amount of time, the server can discard it to save memory. You can explicitly set a time-out value for a single Session object by using the Setmaxinactiveinterval method of HttpSession, or you can use the Session-config element to make a default timeout<mime-mapping></mime-mapping>The mime-mapping element provides this assurance if the Web app has a special file that you want to guarantee to assign to them a specific MIME type .<welcome-file-list></welcome-file-list>indicates which file the server uses when it receives a URL referencing a directory name instead of a file name (in fact the welcome interface or the portal interface is generally index.*)<Error-page></Error-page>When a specific HTTP status code is returned, or when a particular type of exception is thrown, the page that will be displayed is made. <taglib></taglib>specifies an alias for the tag Library descriptor file (tag Libraryu descriptor files). This feature enables you to change the location of TLD files without editing the JSP pages that use those files. <Resource-env-ref></Resource-env-ref>declares a management object that is associated with a resource. <Resource-ref></Resource-ref>declares an external resource used by a resource factory. <Security-constraint></Security-constraint>develop URLs that should be protected. It is used in conjunction with the Login-config element<Login-config></Login-config>specifies how the server should authorize users attempting to access a protected page. It is used in conjunction with the Sercurity-constraint element. <Security-role></Security-role>gives a list of security roles that will appear in the Role-name child elements of the security-role-ref element within the servlet element. Declaring roles separately makes it easier for advanced Ides to handle security information<Env-entry></Env-entry>declaring environment items for Web apps</Web-app>

In the process of configuring the project components, it is necessary to understand the sequence of tomcat load components. For example, some frameworks such as the Quartz cluster feature require database support, and the loading of the database must be before the framework component is loaded.

After lookup and debug discovery, the Web. XML component is loaded in the following order: Context-param, Listener, filter, and servlet (the same class is executed in writing order).

Web. XML Component Load Order

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.