过滤器在Struts2中不起作用 [英] Filters not working in Struts2

查看:121
本文介绍了过滤器在Struts2中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些未知原因,我无法在struts2上使用过滤器。我正在使用apache tomcat并使用过滤器限制用户访问(我喜欢而不是拦截器)。我的请求 / tela-paciente 是否有任何理由没有被过滤?

for some unknown reason I'm not being able to use filter on struts2. I'm using apache tomcat and using filter to restrict user access ( I preffer rather than Interceptors). Is there any reason why my requests with /tela-paciente is not being filtering??

   <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

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

    <filter>
        <filter-name>Paciente</filter-name>
        <filter-class>br.ufg.inf.sas.filtros.FiltroPaciente</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>Paciente</filter-name>
        <url-pattern>/tela-paciente</url-pattern>
    </filter-mapping>


推荐答案

您是否尝试将过滤器映射设置为/ tela -paciente / *(< url-pattern> / tela-paciente / *< / url-pattern> )代替?

Have you tried setting the filter mapping to "/tela-paciente/*" (<url-pattern>/tela-paciente/*</url-pattern>) instead?

您的问题是一个tomcat问题,该特定映射中没有任何内容与struts相关。

Your question is a tomcat question, there is nothing in that particular mapping that relates to struts.

Steven Benitez的下面的陈述是正确的 - 我的不好(没有人会去你的安全过滤器)。

The statement below by Steven Benitez is correct - my bad ("none will go to your security filter").

关于过滤器的更多一般信息:除非其中一个过滤器停止,否则它们会被处理通过不调用过滤器链进行处理(这可能就是这种情况 - 但这应该是一种罕见的事情,仅在处理异常,重定向URL或阻止页面加载时使用)。您可以将多个过滤器绑定到重叠的URL集。

More general info on filters: they are processed unless one of the filters stops the processing by not calling down the filter chain (which may be the case here - this should be a rare thing though, to be used only when dealing with exceptions, when redirecting URLs or to prevent the page from loading). You can have as many filters as you like bound to overlapping sets of URLs.

这篇关于过滤器在Struts2中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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