此文转载自
http://blog.csdn.net/zhaoyh82/archive/2009/06/18/4278896.aspx
更多详细内容请看上面原文!
在项目中总会遇到一些关于加载的优先级问题,近期也同样遇到过类似的,所以自己查找资料总结了下,下面有些是转载其他人的,毕竟人家写的不错,自己也就不重复造轮子了,只是略加点了自己的修饰。
首先可以肯定的是,加载顺序与它们在 web.xml 文件中的先后顺序无关。即不会因为 filter 写在 listener 的前面而会先加载 filter。最终得出的结论是:listener -> filter -> servlet
同时还存在着这样一种配置节:context-param,它用于向 ServletContext 提供键值对,即应用程序上下文信息。我们的 listener, filter 等在初始化时会用到这些上下文中的信息,那么 context-param 配置节是不是应该写在 listener 配置节前呢?实际上 context-param 配置节可写在任意位置,因此真正的加载顺序为:context-param -> listener -> filter -> servlet
分享到:
相关推荐
本文将对 web.xml 的配置进行详细的解释,包括加载顺序、context-param、listener、filter、servlet 等配置节的使用和顺序。 加载顺序 ---------- 加载顺序是指 web.xml 文件中的元素出现的顺序,它对 Web 应用...
web.xml 文件的加载顺序是:context-param -> listener -> filter -> servlet。在这个顺序中,context-param 元素将被首先加载,然后是 listener 元素,接着是 filter 元素,最后是 servlet 元素。 结论 web.xml ...
部署描述文件web.xml详解(web-app_2_3.dtd),全面介绍: 1. icon元素 2. display-name元素 3. description元素 4. distributable元素 5. context-param元素 6. filter元素 7. filter-mapping元素 8. ...
"J2EE 中关于 web.xml 文件的配置" 在 J2EE 中,web.xml 文件扮演着非常重要的角色,它是一个基于 XML 的配置文件,用于描述 Web 应用的各个方面的配置信息。通过 web.xml 文件,我们可以对 Web 应用进行配置,例如...
org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <filter> <filter-name>encodingFilter</filter-name> <filter-class> org.springframework.web.filter....
`<servlet-name>` 指定 servlet 的名字,这个名字在同一个 Web 应用程序中必须是唯一的。 `<servlet-class>` 指定 servlet 类的完整限定名。 `<jsp-file>` 指定在 Web 应用程序中的 jsp 文件的完整路径,该路径以...
本书共分4部分,从xml、servlet、jsp和应用的角度向读者展示了java web开发中各种技术的应用,循序渐进地引导读者快速掌握java web开发。. 本书内容全面,涵盖了从事java web开发所应掌握的所有知识。在知识的讲解...
org.springframework.web.servlet-3.1.3.RELEASE.jar org.springframework.web.struts-3.1.3.RELEASE.jar 加入struts的配置文件struts.xml 在web.xml中配置struts <filter> <filter-name>struts2</filter-name> ...
本书共分4部分,从xml、servlet、jsp和应用的角度向读者展示了java web开发中各种技术的应用,循序渐进地引导读者快速掌握java web开发。. 本书内容全面,涵盖了从事java web开发所应掌握的所有知识。在知识的讲解...
36 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 37 <load-on-startup>1</load-on-startup> 38 </servlet> 39 40 <servlet-mapping> 41 <servlet-name>ideawu</servlet-name...
1.6.1 监听器(Listener)顺序 ...............................................................................................................14 1.6.2 注解处理 .............................................
本文后面的章节将从数据持久层->业务层->Web层的开发顺序,逐层讲解文件上传下载的开发过程。 数据持久层 1、领域对象及映射文件 您可以使用Hibernate Middlegen、HIbernate Tools、Hibernate ...
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/dispatcher-servlet.xml</...
—要和<servlet-mapping>中的<servlet-name>一致--> <servlet-name>Faces Servlet</servlet-name> </filter-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> ...
本书共分4部分,从xml、servlet、jsp和应用的角度向读者展示了java web开发中各种技术的应用,循序渐进地引导读者快速掌握java web开发。. 本书内容全面,涵盖了从事java web开发所应掌握的所有知识。在知识的讲解...
1.6.1 监听器(Listener)顺序 ...............................................................................................................14 1.6.2 注解处理 ...............................................
本书共分4部分,从xml、servlet、jsp和应用的角度向读者展示了java web开发中各种技术的应用,循序渐进地引导读者快速掌握java web开发。. 本书内容全面,涵盖了从事java web开发所应掌握的所有知识。在知识的讲解...
Controlling Web Application Behavior with web.xml Section 2.1. Purpose of the Deployment Descriptor Section 2.2. Defining the Header and the Root Element Section 2.3. The Elements of web.xml ...
Controlling Web Application Behavior with web.xml Section 2.1. Purpose of the Deployment Descriptor Section 2.2. Defining the Header and the Root Element Section 2.3. The Elements of web.xml ...
XML .............................................................................................................................................. 51 SOAP Transport Protocol .............................