OSChina 网站的 web.xml 文件

web.xml 是 Java Web 项目的核心配置文件,看看 oschina 的这个文件长什么样吧?

[1].[代码] web.xml 跳至 [1]

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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:web="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">
    <display-name>OSChina.NET</display-name>
    
    <!-- filters -->
    <filter>
        <filter-name>global</filter-name>
        <filter-class>net.oschina.OSChinaFilter</filter-class>
    </filter>
    <filter>
        <filter-name>myspace</filter-name>
        <filter-class>net.oschina.MySpaceFilter</filter-class>
        <init-param>
            <param-name>domain</param-name>
            <param-value>my.oschina.net</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>global</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <filter-mapping>
        <filter-name>myspace</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <!-- servlets -->
    <servlet>
        <servlet-name>velocity</servlet-name>
        <servlet-class>my.view.VelocityServlet</servlet-class>
        <init-param>
            <param-name>org.apache.velocity.toolbox</param-name>
            <param-value>/WEB-INF/conf/velocity-toolbox.xml</param-value>
        </init-param>
        <init-param>
            <param-name>org.apache.velocity.properties</param-name>
            <param-value>/WEB-INF/conf/velocity.properties</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>controller</servlet-name>
        <servlet-class>my.mvc.ActionServlet</servlet-class>
        <init-param>
            <param-name>packages</param-name>
            <!-- 多个包请用逗号隔开 -->
            <param-value>net.oschina.action</param-value>
        </init-param>
        <init-param>
            <param-name>initial_actions</param-name>
            <!-- 多个类请用逗号隔开 -->
            <param-value>visit</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
    
    <servlet>
        <servlet-name>mapping</servlet-name>
        <servlet-class>my.view.URLMappingServlet</servlet-class>
        <init-param><!-- WAP页面路径 -->
            <param-name>wap</param-name>
            <param-value>/WEB-INF/wap/</param-value>
        </init-param>
        <init-param><!-- WAP页面路径 -->
            <param-name>m</param-name>
            <param-value>/WEB-INF/wap/</param-value>
        </init-param>
        <init-param><!-- CSDN合作频道页面路径 -->
            <param-name>opensource.csdn.net</param-name>
            <param-value>/WEB-INF/csdn/</param-value>
        </init-param>
        <init-param><!-- CSDN合作频道页面路径 -->
            <param-name>csdn</param-name>
            <param-value>/WEB-INF/csdn/</param-value>
        </init-param>
        <init-param><!-- WEB页面路径 -->
            <param-name>default</param-name>
            <param-value>/WEB-INF/www/</param-value>
        </init-param>
        <init-param>
            <param-name>myspace</param-name>
            <param-value>/WEB-INF/myspace/</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>velocity</servlet-name>
        <url-pattern>*.vm</url-pattern>
    </servlet-mapping>
    
    <servlet-mapping>
        <servlet-name>velocity</servlet-name>
        <url-pattern>/sitemap.xml</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>controller</servlet-name>
        <url-pattern>/action/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>mapping</servlet-name>
        
        <url-pattern>/home/*</url-pattern<!-- 首页 -->
        <url-pattern>/shop/*</url-pattern<!-- 团购 -->
        <url-pattern>/user/*</url-pattern<!-- 用户页 -->
        <url-pattern>/project/*</url-pattern>   <!-- 项目页 -->
        <url-pattern>/p/*</url-pattern>
        <url-pattern>/blog/*</url-pattern<!-- 博客频道 -->
        <url-pattern>/news/*</url-pattern<!-- 新闻频道 -->
        <url-pattern>/bbs/*</url-pattern>
        <url-pattern>/code/*</url-pattern<!-- Code Snipplet-->
        <url-pattern>/help/*</url-pattern>
        <url-pattern>/widgets/*</url-pattern>   <!-- Widgets -->
        <url-pattern>/admin/*</url-pattern> <!-- 管理页 -->
    </servlet-mapping>
    
    <!-- servlet config -->
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.vm</welcome-file>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <error-page>
        <error-code>403</error-code>
        <location>/403.html</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/404.vm</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/500.vm</location>
    </error-page>
</web-app>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。