Reputation: 4106
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>
Upvotes: 3
Views: 4816
Reputation: 1311
Have you tried setting the filter mapping to "/tela-paciente/*" (<url-pattern>/tela-paciente/*</url-pattern>
) instead?
Your question is a tomcat question, there is nothing in that particular mapping that relates to struts.
The statement below by Steven Benitez is correct - my bad ("none will go to your security filter").
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.
Upvotes: 2
Reputation: 11055
Another thing to keep in mind is that in your example the mapping for /tela-paciente occurs after the mapping for /* (for the Struts2 filter), so all requests will be mapped to Struts2 and none will go to your security filter.
Remember that the order of your filters matters. :)
@totaam: The StrutsPrepareAndExecuteFilter
does not chain on to other filters unless:
struts.action.excludePattern
propertyTherefore, assuming his request does map to an action, his security filter will not be invoked if it is mapped after the Struts2 filter.
Upvotes: 3