问题
Following is outline of what I have in my web.xml config file. I need help putting this into the correct order.
web.xml web-app
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
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.
I have organized it as per BalusC's suggestions. Any idea why is this happening?
Where should the session-config go?
回答1:
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.
来源:https://stackoverflow.com/questions/5452804/adjusting-web-xml-listeners-filters-and-servlets