调整 web.xml 侦听器、过滤器和 servlet [英] Adjusting web.xml listeners, filters and servlets

查看:46
本文介绍了调整 web.xml 侦听器、过滤器和 servlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我在 web.xml 配置文件中的概要.我需要帮助将其按正确顺序排列.

Following is outline of what I have in my web.xml config file. I need help putting this into the correct order.

 1. contextConfigLocation applicationContext.xml
 2. defaultHtmlEscape true
 3. listeners 
 4. servlets 
 5. filters <order sensitive>    
 6. session-config timeout 120
 7. error page 404 500


更新:

我在 tomcat 的日志/localhost.log 中的所有侦听器上都收到 ClassNotFoundException应用程序启动后没有问题,只是日志条目表明某些事情已关闭.


UPDATE:

I'm getting ClassNotFoundException on all my listeners in tomcat's logs/localhost.log There are not problems after the application starts just log entries that indicate that something is off.

我按照 BalusC 的建议组织了它.知道为什么会这样吗?

I have organized it as per BalusC's suggestions. Any idea why is this happening?

会话配置应该去哪里?

推荐答案

只有 元素的顺序是相关的.每当请求 URL 与多个过滤器的 url-pattern 匹配时,这将是过滤器被调用的实际顺序.过滤器可以决定是否继续该链.残余对 web 应用程序的功能没有显着影响.只需遵守 DTD/XSD(如果有)中指定的顺序和/或任何您认为可以使可读/可维护性最佳的顺序.通常,顺序如下:上下文参数、侦听器、servlet、过滤器和错误/欢迎页面.

Only the order of the <filter-mapping> elements is relevant. It will be the actual order how the filters are invoked whenever the request URL matches the url-pattern of more than one filter. A filter can namely decide whether to continue the chain or not. The remnant has no significant influence on the functioning of the webapp. Just adhere the ordering as specified in DTD/XSD (if any) and/or whatever you feels it makes the best readable/maintainable. Generally, the ordering is as follows: context params, listeners, servlets, filters and error/welcome pages.

这篇关于调整 web.xml 侦听器、过滤器和 servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆