0

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>

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?

4

2 回答 2

2

<dispatcher>支持是在 Servlet 2.4 中引入的。因此,当它不起作用时,很可能意味着您正在过时的 Servlet 2.3 容器(例如 Tomcat 5.0)上运行您的 webapp,或者您web.xml是按照 Servlet 2.3 DTD 声明的,或者根本没有特定于版本的声明这将迫使容器退回到最低兼容性模式。

请确保您web.xml声明的符合目标运行时支持的最大 Servlet API 版本。例如,当您的目标运行时是 Tomcat 6.0(它是一个 Servlet 2.5 容器)时,您应该声明web.xml符合 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>
于 2011-06-13T13:15:32.157 回答
0

这应该有效。<dispatcher>INCLUDE</dispatcher>在您的过滤器映射中说,还包括用于包含调度的过滤器。

调试你的代码,其他地方出错了。

于 2011-06-13T13:04:53.833 回答