serverlet Web.xml配置代碼解釋
阿新 • • 發佈:2017-10-31
pattern 提供服務 instance lis pat java acl tro login
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>testservletjava5</display-name> <welcome-file-list> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <!-- servlet生命周期 1、web容器加載 2、init 3、service(提供服務)4、銷毀(destroy) --> <!-- 配置servlet的類及名字 --> <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>com.oracleoaec.servlet.p1.HelloServlet</servlet-class> <init-param> <param-name>test</param-name> <param-value>wanger</param-value> </init-param> <!-- 0為啟動web容器時就加載servlet 加載順序是由小到大順序加載 ,小於0的話是訪問時加載--> <load-on-startup>1</load-on-startup> </servlet> <!-- 配置訪問地址(url) --> <servlet-mapping> <servlet-name>HelloServlet</servlet-name> <url-pattern>/helloServlet.do</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>HelloServlet</servlet-name> <url-pattern>/helloServlet</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>HelloServlet</servlet-name> <url-pattern>/sakdfshd.abc</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>HelloServlet</servlet-name> <url-pattern>/p1/sakdfshd.abc.abc</url-pattern> </servlet-mapping> <servlet> <servlet-name>HelloServlet2</servlet-name> <servlet-class>com.oracleoaec.servlet.p1.HelloServlet2</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet> <servlet-name>LoginServlet</servlet-name> <servlet-class>com.oracleoaec.servlet.p1.LoginServlet</servlet-class> </servlet> <servlet> <servlet-name>LogoutServlet</servlet-name> <servlet-class>com.oracleoaec.servlet.p1.LogoutServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloServlet2</servlet-name> <url-pattern>/helloServlet2.do</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>LoginServlet</servlet-name> <url-pattern>/loginServlet.do</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>LogoutServlet</servlet-name> <url-pattern>/logoutServlet.do</url-pattern> </servlet-mapping> </web-app>
serverlet Web.xml配置代碼解釋