zhitong.yu
2024-12-27 8abbee975353926e51a426a75c67119337fbdae4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?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_4_0.xsd"
         version="4.0"
         metadata-complete="true">
 
    <!--在web项目中注册SpringMVC的控制器:把所有的请求都交给spring的控制器处理-->
    <!--Single Page Application-->
 
    <servlet>
        <servlet-name>springDispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
 
    <servlet-mapping>
        <servlet-name>springDispatcherServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <!--针对 post 乱码-->
    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>com.hxzk.util.EncodingFilter</filter-class> <!-- 自定义过滤器类 -->
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value> <!-- 设置为你希望使用的字符编码 -->
        </init-param>
    </filter>
 
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern> <!-- 设置过滤器的作用路径 -->
    </filter-mapping>
 
 
 
 
 
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
 
    <error-page>
        <error-code>404</error-code>
        <location>/error_page/error_400/page_1/404.html</location>
    </error-page>
    <error-page>
        <error-code>405</error-code>
        <location>/error_page/error_400/page_1/404.html</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/error_page/error_500/page_2/500.html</location>
    </error-page>
 
 
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Protected Servlet</web-resource-name>
            <url-pattern>/servlets/servlet/SessionExample</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <!-- 无人可访问 -->
            <role-name>none</role-name>
        </auth-constraint>
    </security-constraint>
</web-app>