Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
web.xml-Javaservlet过滤器和WebSphere-URL模式问题_Java_Websphere_Web.xml_Servlet Filters - Fatal编程技术网

web.xml-Javaservlet过滤器和WebSphere-URL模式问题

web.xml-Javaservlet过滤器和WebSphere-URL模式问题,java,websphere,web.xml,servlet-filters,Java,Websphere,Web.xml,Servlet Filters,因此,我们正在运行一个已经在Tomcat、Glassfish、WebLogic和WebSphere上测试过的web应用程序。除WebSphere外,所有服务器都正常运行。问题是没有为特定目录下的文件处理筛选器 例如,我有一个从浏览器cookies检查用户语言的过滤器,还有一个获取用户用户名的过滤器,在web.xml中,配置如下: <!-- ****************************** --> <!-- * Security context filtering *

因此,我们正在运行一个已经在Tomcat、Glassfish、WebLogic和WebSphere上测试过的web应用程序。除WebSphere外,所有服务器都正常运行。问题是没有为特定目录下的文件处理筛选器

例如,我有一个从浏览器cookies检查用户语言的过滤器,还有一个获取用户用户名的过滤器,在web.xml中,配置如下:

<!-- ****************************** -->
<!-- * Security context filtering * -->
<!-- ****************************** -->

<filter>
    <filter-name>SetSecurityContextFilter</filter-name>
    <filter-class>
        com.test.security.SecurityContextServletFilter
    </filter-class>
</filter>

<!-- ****************************** -->
<!-- ** Locale context filtering ** -->
<!-- ****************************** -->

<filter>
    <filter-name>SetLocaleFilter</filter-name>
    <filter-class>
        com.test.locale.LocaleServletFilter
    </filter-class>
</filter>

<filter-mapping>
    <filter-name>SetSecurityContextFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
    <filter-name>SetLocaleFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping> 

SetSecurityContextFilter
com.test.security.SecurityContextServletFilter
SetLocaleFilter
com.test.locale.LocaleServletFilter
SetSecurityContextFilter
/*
SetLocaleFilter
/*
这两个过滤器都设置了一个静态threadlocal变量,可以从静态getter访问该变量,但是当同一个文件“test.jsp”调用getter时,在“contextroot/js”下它们返回默认值(就像未设置的一样),而在“contextroot/pages”下它们是正确的

有什么想法吗


提前谢谢。

我发现了问题所在

在我的web.xml中,我有以下内容:

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Test Application</web-resource-name>
            <url-pattern>/pages/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
             ...
        </auth-constraint>
    </security-constraint>

测试应用
/页数/*
...
如果我将URL模式更改为“/*”,以便上下文根目录下的每个页面都需要登录,那么所有过滤器都会一直正确运行。但这并不意味着我的登录页面无法访问任何css文件,但这是另一个问题


干杯

将登录页面定义为表单登录页面可能有助于获取css资源 如下


/jsp也可能值得一提;我们在UNIX上测试了WebSphere,其他的都是在Windows上测试的?我看不出过滤器定义有什么问题,所以可能是代码中的某些东西,您的过滤器是否编写调试信息以便您可以看到它们是否被调用?是的,AIX。这似乎不太可能是代码,不是吗?…sinc所有其他web容器都能很好地处理这个问题。不幸的是,我目前没有任何日志记录,所以不能100%地说它们没有被调用-这需要一些时间,但我会尝试让过滤器做一些日志记录。干杯