Servlet-02-xml configuration file


 

Servlet web.xml configuration:

Web.xml configuration action:

Protection Servlet.

A configuration: the precise configuration

<url-pattern>/my3</url-pattern>

/ My3 search page after only a virtual project name.

<servlet>
<servlet-name>my3servlet-name>
<servlet
class>com.bjsxt.servlet.MyServlet3servlet-class>
servlet>
<servlet-mapping>
<servlet-name>my3servlet-name>
<url-pattern>/my3url-pattern>
servlet-mapping>
 

Configuring way: fuzzy Configuration

<url-pattern>/*.do</url-pattern>

This said, ending .do any, can be found. This is mainly used for modular development.

<servlet>
<servlet-name>my3servlet-name>
<servlet-class>com.bjsxt.servlet.MyServlet3servlet-class>
<servlet>
<servlet-mapping><servlet-name>my3servlet-name>
<url-pattern>*.do<url-pattern>
<servlet-mapping>

Configuration Three ways: to intercept all requests configuration

<url-pattern>/*</url-pattern>

Whether the virtual project name, / what can be found. It intercepts all manner of requests, including static resource request (css, js, etc.) and jsp.

 

Configuration IV: intercept all requests in a single directory

<url-pattern>/one/*</url-pattern>

It intercepts all requests to the / one.

<servlet>
<servlet-name>my3servlet-name>
<servlet-class>com.bjsxt.servlet.MyServlet3<servlet-class>
<servlet>
<servlet-mapping>
<servlet-name>my3servlet-name>
<url-pattern>/one/*url-pattern>
<servlet-mapping>

note:
There may have a plurality of Servlet url-pattern configuration, but a configuration url-pattern corresponds to only one Servlet
 

Virtual Project name:

Jargon, means: we write, then Tomcat server webApp folder, the name of the project layout.

Servlet by invoking the process of learning, we know web.xml configuration file in order to protect the servlet. In fact, the server should call which servlet for processing requests, written very clearly in the request the address of the browser.
 

Load opportunity:

The server is started when the project will be deployed in the webapps unified loaded, and finished loading web.xml file for each item.
 

Guess you like

Origin www.cnblogs.com/EricShen/p/11442641.html