为方便起见,直接附上一个web.xml文件,然后加注释介绍。
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE web-app
3 PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
4 "http://java.sun.com/dtd/web-app_2_3.dtd">
5 <web-app>
6 <display-name>dwmis框架系统</display-name>
7 <description>dwmis框架系统</description>
8 <!--上下文参数:声明应用范围内的初始化参数-->
9 <context-param>
10 <param-name>log4jConfigLocation</param-name>
11 <param-value>/WEB-INF/log4j.properties</param-value>
12 </context-param>
13 <context-param>
14 <param-name>webAppRootKey</param-name>
15 <param-value>dwmis.root</param-value>
16 </context-param>
18 <context-param>
19 <param-name>contextConfigLocation</param-name>
20 <param-value>/WEB-INF/applicationContext.xml</param-value>
21 </context-param>
22 <!--过滤器定义。Servlet版本2.3引入了过滤器的概念。过滤器可截取和修改一个Servlet或JSP页面的请求或
或从一个Servlet或JSP页面发出的响应。过滤器具有对到来的ServletRequest对象的全部访问权,因此可
可以查看客户机名、查找到来的cookie等。-->
23 <filter>
24 <filter-name>Encoding</filter-name>
25 <filter-class>
26 com.dareway.framework.filter.EncodingFilter
27 </filter-class>
28 <init-param>
29 <param-name>encoding</param-name>
30 <param-value>GBK</param-value>
31 </init-param>
32 </filter>
33 <filter>
34 <filter-name>SafetyFilter</filter-name>
35 <filter-class>
36 com.dareway.framework.filter.SafetyFilter
37 </filter-class>
38 </filter>
39 <!--过滤器映射:可使用filter-name和servlet-name子元素把过滤器与一个特定的Servlet名关联;也可以用filter-name和
url-pattern子元素将过滤器与一组Servlet、JSP页面或静态内容相关联。->
40 <filter-mapping>
41 <filter-name>Encoding</filter-name>
42 <url-pattern>/*</url-pattern>
43 </filter-mapping>
44 <filter-mapping>
45 <filter-name>SafetyFilter</filter-name>
46 <servlet-name>dwmis</servlet-name>
47 </filter-mapping>
48 <!--监听器:事件监听程序在建立、修改和删除会话或Servlet环境时,得到通知。listener元素指出事件监听程序类-->
54 <listener>
55 <listener-class>
56 com.dareway.framework.log4j.Log4jConfigListener
57 </listener-class>
58 </listener>
59 <listener>
60 <listener-class>
61 com.dareway.framework.plugin.AppContextPlugIn
62 </listener-class>
63 </listener>
64 <!--Servlet定义:在向Servlet或JSP页面制定初始化参数或定制URL时,必须首先命名Servlet或JSP页面-->
65 <servlet>
66 <servlet-name>context</servlet-name>
67 <servlet-class>
68 org.springframework.web.context.ContextLoaderServlet
69 </servlet-class>
70 <load-on-startup>1</load-on-startup>
71 </servlet>
72
73 <servlet>
74 <servlet-name>dwmis</servlet-name>
75 <servlet-class>
76 org.springframework.web.servlet.DispatcherServlet
77 </servlet-class>
78 <init-param>
79 <param-name>contextConfigLocation</param-name>
80 <param-value>/WEB-INF/dwmis-servlet.xml</param-value>
81 </init-param>
82 <init-param>
83 <param-name>charset</param-name>
84 <param-value>GBK</param-value>
85 </init-param>
86 <load-on-startup>2</load-on-startup>
87 </servlet>
88 <!--Servlet映射:服务器一般为servlet提供一个默认的URL:http://host/webAppPrefix/servlet/ServletName.
104 但是,常常会更改这个URL,一边servlet开一个访问初始化数据或更容易处理相对URL。-->
105 <servlet-mapping>
106 <servlet-name>dwmis</servlet-name>
107 <url-pattern>*.do</url-pattern>
108 </servlet-mapping>
109
110 <servlet-mapping>
111 <servlet-name>treeServlet</servlet-name>
112 <url-pattern>/treeServlet</url-pattern>
113 </servlet-mapping>
114
115 <servlet-mapping>
116 <servlet-name>AxisServlet</servlet-name>
117 <url-pattern>/services/*</url-pattern>
118 </servlet-mapping>
119 <!--控制会话超时-->
120 <session-config>
121 <session-timeout>60</session-timeout>
122 </session-config>
123 <!--欢迎制定文件-->
124 <welcome-file-list>
125 <welcome-file>logonDialog.jsp</welcome-file>
126 </welcome-file-list>
127 <!--定位TLD:taglib元素对标记库描述符文件(Tag Librayu Descriptor file)指定别名。此功能使你能够更改TLD文件的位置,
128 而不用编辑使用这些文件的JSP页面-->
129 <taglib>
130 <taglib-uri>darewayBS.tld</taglib-uri>
131 <taglib-location>/WEB-INF/darewayBS.tld</taglib-location>
132 </taglib>
133 <taglib>
134 <taglib-uri>darewayForJSP.tld</taglib-uri>
135 <taglib-location>/WEB-INF/darewayForJSP.tld</taglib-location>
136 </taglib>
137 </web-app>