web.xml配置

Posted 好记性不如烂笔头

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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版本为3.1 -->
    <!-- 配置DispatcherServlet -->
    <servlet>
        <servlet-name>DispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <!-- 配置springMVC需要加载的配置文件
            spring-dao.xml,spring-service.xml,spring-web.xml
            Mybatis -> spring -> springMVC
         -->
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring/spring-*.xml</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>DispatcherServlet</servlet-name>
        <!-- 默认匹配所有的请求 -->
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

IDEA工具指的resources文件夹,如下图:

 

 

 

myeclipse工具直接指的src目录下,如下图:

 

 

以上是关于web.xml配置的主要内容,如果未能解决你的问题,请参考以下文章

简单的web.xml配置代码

最新的web.xml配置代码

serverlet Web.xml配置代码解释

配置ssm 时, web.xml 文件无 # 自动代码提示

Spring使用代码配置Web.xml

ServletConfig对象和ServletContext对象