Using Servlet Mapping with Struts 2

April 22, 2013

I had a struts 2 web application, and I wanted to call some code that was implemented as a pure java servlet. Struts 2 uses a servlet filter:


and I wanted to setup a new servlet that matched by url:


This didn't work - requests for /card/* were handled by the struts 2 filter, and treated as a struts 2 action.


Struts 2 has support for ignoring requests for static content - I managed to use this feature to tell struts 2 to ignore the /card/* url.

At the bottom of struts.xml I added the following constant:

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