• 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页面充当首页,依此类推。

  • 相关阅读:
    Redis简介(数据结构,哨兵、集群和SpringDataRedis)
    FastDFS + Nginx
    Dubbo
    Ubuntu下Zookeeper的安装和基本使用
    RMI简介
    RPC
    各大技术团队的博客
    天了噜,为什么外链css要放在头部,js要放在尾部?
    月经帖 | 2019.11
    前端面试知识点
  • 原文地址:https://www.cnblogs.com/tufujie/p/5177231.html
Copyright © 2020-2023  润新知