virtual path
In the Web. xml file, a <Servlet-mapping> element
Used to map the external access path of a servlet, which is called a virtual path
For example, Helloworldservlet, the mapped virtual path is
/helloworldservlet
Create a virtual path to the servlet so that the client can access the servlet's multiple mappings
Refers to the same servlet, which can be mapped to multiple virtual paths
Clients can implement access to the same servlet through multiple paths
Servlet Multi-mapping is implemented in two configurations with multiple <servlet-mapping> elements
Sample code
<servlet>
<description></description>
<display-name>testservlet01</ display-name>
<servlet-name>TestServlet01</servlet-name>
<servlet-class> cn.itcast.chapter04.servlet.testservlet01</servlet-class>
</servlet>
<!--map to Servlet01-- >
<servlet-mapping>
<servlet-name>TestServlet01</servlet-name>
< url-pattern>/servlet01</url-pattern>
</servlet-mapping>
<!--map to Servlet02--
<servlet-mapping>
<servlet-name>TestServlet01</servlet-name>
<url-pattern >/Servlet02</url-pattern>
</servlet-mapping>
Visit Servlet01
Visit Servlet02
Access to all two addresses TestServlet01
By configuring multiple <servlet-mapping> elements, you can configure multiple <url-pattern> child elements for a servlet's Multimap
In a <servlet-mapping> element, configure multiple <url-pattern> child elements
Sample code
<servlet>
<description></description>
<display-name>testservlet01</ display-name>
<servlet-name>TestServlet01</servlet-name>
<servlet-class> cn.itcast.chapter04.servlet.testservlet01</servlet-class>
</servlet>
<!-- Maps to Servlet01 and Servlet02-
<servlet-mapping>
<servlet-name>testservlet01</ servlet-name>
<url-pattern>/Servlet01</url-pattern>
<url-pattern>/servlet02</ Url-pattern>
</servlet-mapping>
Visit Servlet01
Visit Servlet02
Two servlet paths can be accessed TestServlet01
By configuring multiple <url-pattern> child elements in a <servlet-mapping> element
You can also implement multiple mappings for a servlet