Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter mapping for everything to Struts2 besides one servlet?

I have a Struts2 (2.1.8.1) web application. My web.xml looks like,

  <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>

This is configured to map all requests to the struts filter. I want to add a servlet in my web application. I want to send all requests with a certain url pattern to that servlet. I want everything else to go to my struts servlet.

I know I could only map "*.action" to the struts servlet, but I hate .action being on the end of all my URL's.

like image 967
Andy Avatar asked Oct 01 '10 23:10

Andy


1 Answers

In your struts.xml add:

<constant name="struts.action.excludePattern" value="/ServletToExcludeFromStruts*"/>

The value be comma delimited as well for multiple exclusions. See http://struts.apache.org/2.2.1/docs/webxml.html

like image 146
Matt Avatar answered Sep 28 '22 19:09

Matt