The development of the Dynamic web module version 3.1 In the eclipse environment simplifies the configuration of Servlet classes in Dynamic web objects without web. xml configuration. <Servlet>,
Before the eclipse environment Dynamic web module version 3.1, configure the Servlet class in the Dynamic web object in web. xml. The image and Code are as follows:
The source code in web. xml is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Web-app xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xmlns = "http://xmlns.jcp.org/xml/ns/javaee"
Xsi: schemaLocation = "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
Id = "WebApp_ID" version = "3.1">
<Display-name> ServletDemo </display-name>
<Welcome-file-list>
<Welcome-file> index.html </welcome-file>
<Welcome-file> index.htm </welcome-file>
<Welcome-file> index. jsp </welcome-file>
<Welcome-file> default.html </welcome-file>
<Welcome-file> default.htm </welcome-file>
<Welcome-file> default. jsp </welcome-file>
</Welcome-file-list>
<Servlet>
<Servlet-name> ServletDemo </servlet-name> <! -- Dynamic web object name -->
<Servlet-class> com. swift. servlet. ServletTest </servlet-class> <! -- Name of the newly created Servlet class in the src folder -->
</Servlet>
<Servlet-mapping>
<Servlet-name> ServletDemo </servlet-name> <! -- Dynamic web object name -->
<Url-pattern>/ServletTest </url-pattern> <! -- Everything can be done here. Do not forget that there is a forward slash/URL path on the last side -->
</Servlet-mapping>
</Web-app>
In the eclipse environment, after the Dynamic web module version 3.1, the Servlet class configuration in the Dynamic web object does not need to be configured in web. xml <Servlet>. The times have improved.
You don't need to do anything. The following sentence is all done. ().
@ WebServlet ("/ServletTest ")