1. <?xml version="1.0" encoding="UTF-8"?>
    2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    3. xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    4. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    5. version="3.1">
    6. <!-- 配置加载类路径的配置文件 -->
    7. <context-param>
    8. <param-name>contextConfigLocation</param-name>
    9. <param-value>classpath*:applicationContext.xml,classpath*:spring-security.xml</param-value>
    10. </context-param>
    11. <!-- 配置监听器 -->
    12. <listener>
    13. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    14. </listener>
    15. <!-- 配置监听器,监听request域对象的创建和销毁的 -->
    16. <listener>
    17. <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    18. </listener>
    19. <!-- 前端控制器(加载classpath:springmvc.xml 服务器启动创建servlet) -->
    20. <servlet>
    21. <servlet-name>dispatcherServlet</servlet-name>
    22. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    23. <!-- 配置初始化参数,创建完DispatcherServlet对象,加载springmvc.xml配置文件 -->
    24. <init-param>
    25. <param-name>contextConfigLocation</param-name>
    26. <param-value>classpath:spring-mvc.xml</param-value>
    27. </init-param>
    28. <!-- 服务器启动的时候,让DispatcherServlet对象创建 -->
    29. <load-on-startup>1</load-on-startup>
    30. </servlet>
    31. <servlet-mapping>
    32. <servlet-name>dispatcherServlet</servlet-name>
    33. <url-pattern>*.do</url-pattern>
    34. </servlet-mapping>
    35. <!-- 解决中文乱码过滤器 -->
    36. <filter>
    37. <filter-name>characterEncodingFilter</filter-name>
    38. <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    39. <init-param>
    40. <param-name>encoding</param-name>
    41. <param-value>UTF-8</param-value>
    42. </init-param>
    43. </filter>
    44. <filter-mapping>
    45. <filter-name>characterEncodingFilter</filter-name>
    46. <url-pattern>/*</url-pattern>
    47. </filter-mapping>
    48. <filter>
    49. <filter-name>springSecurityFilterChain</filter-name>
    50. <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    51. </filter>
    52. <filter-mapping>
    53. <filter-name>springSecurityFilterChain</filter-name>
    54. <url-pattern>/*</url-pattern>
    55. </filter-mapping>
    56. <welcome-file-list>
    57. <welcome-file>index.html</welcome-file>
    58. <welcome-file>index.htm</welcome-file>
    59. <welcome-file>index.jsp</welcome-file>
    60. <welcome-file>default.html</welcome-file>
    61. <welcome-file>default.htm</welcome-file>
    62. <welcome-file>default.jsp</welcome-file>
    63. </welcome-file-list>
    64. </web-app>