1.web.xml配置

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3          xmlns="http://java.sun.com/xml/ns/javaee"
 4          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 5          id="WebApp_ID" version="2.5">
 6 
 7     <display-name>Archetype Created Web Application</display-name>
 8 
 9     <!--过滤器的配置,转码作用,也就是-->
10     <filter>
11         <filter-name>characterEncodingFilter</filter-name>
12         <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
13         <init-param>
14             <!--字符集,即将过滤到的request的字符集设置为encoding指定的值,如UTF-8等-->
15             <param-name>encoding</param-name>
16             <param-value>UTF-8</param-value>
17         </init-param>
18         <init-param>
19             <!--这个参数的值只不过是指定response的字符集是否也设置成encoding所指定的字符集,所以你可以选择设置为true或false,当值为true时,表示与encoding相同-->
20             <param-name>forceEncoding</param-name>
21             <param-value>true</param-value>
22         </init-param>
23     </filter>
24     <filter-mapping>
25         <filter-name>characterEncodingFilter</filter-name>
26         <!--拦截的路径是/*,也就是所有路径都拦截-->
27         <url-pattern>/*</url-pattern>
28     </filter-mapping>
29 
30     <!--二期新增重置session时间的filter-->
31     <filter>
32         <filter-name>sessionExpireFilter</filter-name>
33         <filter-class>com.mall.controller.common.SessionExpireFilter</filter-class>
34     </filter>
35     <filter-mapping>
36         <filter-name>sessionExpireFilter</filter-name>
37         <url-pattern>*.do</url-pattern>
38     </filter-mapping>
39 <!--    <filter>
40         <filter-name>springSessionRepositoryFilter</filter-name>
41         <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
42     </filter>
43     <filter-mapping>
44         <filter-name>springSessionRepositoryFilter</filter-name>
45         <url-pattern>*.do</url-pattern>
46     </filter-mapping>-->
47 
48     <listener>
49         <!--将Spring容器与Web容器结合的更加密切,可选配置-->
50         <!--只负责监听web容器启动和关闭的监听器-->
51         <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
52     </listener>
53 
54     <listener>
55         <!--将Web容器与spring容器整合的监听器,必选配置,通过下面配置的applicationContext.xml将web容器和spring进行整合-->
56         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
57     </listener>
58     <context-param>
59         <param-name>contextConfigLocation</param-name>
60         <param-value>
61             classpath:applicationContext.xml
62         </param-value>
63     </context-param>
64 
65     <!--配置springmvc,拦截下面配置的*.do的所有请求,-->
66     <servlet>
67         <servlet-name>dispatcher</servlet-name>
68         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
69         <!-->=0时,容器启动时就会初始化servlet,也就是调用DispatcherServlet中的init()方法-->
70         <!--<0或者不指定时,这个servlet被使用时才会被加载-->
71         <load-on-startup>1</load-on-startup>
72     </servlet>
73 <!--    <servlet-mapping>
74         <servlet-name>dispatcher</servlet-name>
75         <url-pattern>*.do</url-pattern>
76     </servlet-mapping>-->
77 
78     <!--restful-->
79     <servlet-mapping>
80         <servlet-name>dispatcher</servlet-name>
81         <url-pattern>/</url-pattern>
82     </servlet-mapping>
83 </web-app>
View Code

相关文章:

  • 2021-11-28
  • 2021-12-02
  • 2021-12-23
  • 2018-07-24
  • 2022-01-02
  • 2021-07-20
  • 2021-05-20
  • 2022-01-07
猜你喜欢
  • 2022-01-28
  • 2021-06-13
  • 2021-09-14
  • 2022-03-03
  • 2022-01-30
  • 2019-05-17
  • 2021-08-02
相关资源
相似解决方案