serverlet Web.xml配置代码解释

Posted 紫翌

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了serverlet Web.xml配置代码解释相关的知识,希望对你有一定的参考价值。

<?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配置代码解释的主要内容,如果未能解决你的问题,请参考以下文章

serverlet相关

jsp题库啥是serverlet过滤器?作用是?

serverlet各个版本。和各个版本之间的区别

web.xml 配置中 classpath: 与 classpath*: 的区别

简单的web.xml配置代码

最新的web.xml配置代码