jsp:include页面能否通过过滤器 [英] Can jsp:include pages pass through filters
问题描述
我有一个jsp页面,其中包括一个通过jsp:include的jsp页面. 现在的问题是,对包含的jsp的请求是否通过过滤器? 以下是我在web.xml中的过滤器映射
I have a jsp page in which includes a jsp page through jsp:include. Now the question is does the request for the included jsp pass through the filter? following is my filter mapping in web.xml
<filter-mapping>
<filter-name>XYZFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
但这似乎不起作用.不会为包含的jsp调用过滤器. 我在做什么错或者有可能吗?
But this doesnt seem to work. The filter doesn't get called for the included jsp. What am I doing wrong or is it possible at all?
推荐答案
在Servlet 2.4中引入了<dispatcher>
支持.因此,当它不起作用时,则可能意味着您正在过时的Servlet 2.3容器(例如Tomcat 5.0)上运行webapp,或者您的web.xml
已根据Servlet 2.3 DTD声明或没有特定版本声明,这将迫使容器退回到兼容性最低的方式.
The <dispatcher>
support was introduced in Servlet 2.4. So when it does not work, then it likely means that you're running your webapp on an outdated Servlet 2.3 container (Tomcat 5.0 for example) or that your web.xml
is declared as per Servlet 2.3 DTD or does not have a version specific declaration at all which would force the container to fall back to least compatibility modus.
请确保声明您的web.xml
符合目标运行时支持的最大Servlet API版本.例如,当目标运行时是Tomcat 6.0(它是一个Servlet 2.5容器)时,则应声明web.xml
符合Servlet 2.5:
Please ensure that your web.xml
is declared conform the maximum Servlet API version as supported by the target runtime. When your target runtime is for example Tomcat 6.0, which is a Servlet 2.5 container, then you should be declaring the web.xml
conform Servlet 2.5:
<?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/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<!-- Your config here -->
</web-app>
这篇关于jsp:include页面能否通过过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!