The Web. xml file under the Web-inf path (and must be located on that path) for each of the websites is referred to as the configuration descriptor.
For Java Web Apps, Web-inf is a special folder, and the Web container contains the contents of that folder, and the client browser cannot access anything under the Web-inf path.
Before the servlet2.5 specification, most of the components of the Java Web were configured for management through the XML. config file.
Starting with servlet3.0, you can also configure the administration Web Component with annotations, so the. xml file can become more concise.
The contents of Web. XML can be configured:
1. Configure JSP
2. Configuring and Managing Servlets
3. Configuration and Management Listener
4. Configuring and Managing the Filter
5. Configure Tag Library
6. Configure JSP Properties
In addition, Web. XML is also responsible for configuring and managing the following common content.
1. Configure and manage JAAS authorization authentication
2. Configuring and Managing resource references
3. Web Application Home
The root element of the Web. xml file is the <web-app .../> element, which adds the following properties to the SERVLET3.0 specification:
Metadata-complete: This property accepts a value of TRUE or false two properties. When True, the Web app will not load the Web components of the annotation configuration (such as Servlets, Filter, Listener, etc.)
How to configure the homepage:
<welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file> Index.htm</welcome-file> <welcome-file>index.jsp</welcome-file></welcome-file-list >
The above configuration specifies that the first page of the Web application is index.html, index.htm, index.jsp.
If index.html does not exist, then index.htm do the homepage, and so on.
The specific contents are as follows:
<?xml version= "1.0" encoding= "UTF-8"? ><web-app xmlns= "Http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "Http://xmlns.jcp.org/xml/ns/javaee Http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd " version=" 4.0 " metadata-complete=" true ">< welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file> Index.htm</welcome-file> <welcome-file>index.jsp</welcome-file></welcome-file-list ></web-app>
The role of Web. XML in JSP projects