ssm中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">

<!-- 1.编码过滤器 配置这个是拦截所有的资源并设置好编号格式。-->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<!--1.1encoding设置成utf-8就相当于request.setCharacterEncoding("UTF-8"); -->
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<!--1.2foreEncoding设置成true就相当于response.setCharacterEncoding("UTF-8"); -->
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<!--1.3过滤所有的资源 -->
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


<!-- 2.配置DispatcherServlet -->
<servlet>
<servlet-name>SpringMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 2.1配置springMVC需要加载的配置文件
如果不配置默认的路径是/WEB-INF/applicationContext.xml,
在WEB-INF目录下创建的xml文件的名称必须是applicationContext.xml。-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-*.xml</param-value>
</init-param>
<!--2.2如果值为正整数或者0时,表示容器在应用启动时就加载并初始化这个servlet,
值越小,servlet的优先级越高,就越先被加载。 -->
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>SpringMVC</servlet-name>
<!-- 2.3匹配所有请求 只能是两种 *.do 或者/ -->
<url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>

 逆向工程使用:https://www.cnblogs.com/QQ931697811/p/5190911.html

高手的简洁配置:https://www.cnblogs.com/liangguangqiong/p/7965778.html

posted @ 2019-06-28 00:13  我差两天十八岁  阅读(567)  评论(0编辑  收藏  举报