zoukankan      html  css  js  c++  java
  • web.xml详解

    web.xml规范:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                          http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
      version="3.1"
      metadata-complete="true">
    <!-- 根据servlet规范,需要将servlet部署到web.xml文件中-->
       <servlet>
       <!-- servlet-name给该servlet取名,该名字可以自己定义,默认不变-->
          <servlet-name>MyFirstServlet</servlet-name>
          <!--servlet-class要指明servlet是放在哪个包下的,同时形式如下:包/类-->
          <servlet-class>com.tfj.MyFirstServlet</servlet-class>
        </servlet>
        <!--servlet的映射-->
         <servlet-mapping>
         <!--这个servlet名字跟上面的名字一样-->
            <servlet-name>MyFirstServlet</servlet-name>
            <!--url-pattern这里就是将来访问该servlet的部分-->
            <url-pattern>/MyFirstServlet</url-pattern>
        </servlet-mapping>
    </web-app>

    配置首页:

    配置首页使用welcome-file-llst元素,该元素包含多个welcome-file子元素,其中每个welcome子元素配置一个首页。例如下面配置:

    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    </welcome-file-list>

    上面的配置信息指定该Web应用的首页依次是index.jsp,index.html,index.htm,当Web应用中包含index.jsp页面时,如果浏览者直接访问该Web应用,系统将会把该jsp页面呈现给浏览者;当index.html不存在时,则由index.html页面充当首页,依此类推。

  • 相关阅读:
    SpringBoot+SpringCloud+vue+Element开发项目——集成Druid数据源
    SpringBoot+SpringCloud+vue+Element开发项目——集成MyBatis框架
    c语言double类型数据四舍五入
    陀螺仪、加速计、磁力计等传感器汇总 (转)
    sudo和man的tab自动补全
    linux系统资源网站
    gstreamer
    version `GLIBC_2.14' not found 解决方法.
    项目框架设计模式(转)
    Linux音频编程指南(转)
  • 原文地址:https://www.cnblogs.com/tufujie/p/5177231.html
Copyright © 2011-2022 走看看