Search code examples
xmlstruts2web.xmlurl-pattern

Changing URL pattern to specific redirection in Struts 2 filter


Currently in our web.xml, it's going to Struts 2 filter for all the urls since it's /*, but I need to give specific URL pattern (eg: /docupload/*) because I am integrating with another application now.

So another application URL also goes through Struts filter and not working.

            <filtermapping><url-pattern>/*</url-pattern><filtermapping>   

I tried this: I gave "namspace" in struts.xml like 'docupload':

  <constant name="struts.devMode" value="true" />
  <package name="default" namespace="/docupload" extends="struts-default">

Added the namespace as /docupload and below is my folder structure

-created docupload folder under jsp-

in web.xml -

       <url-pattern>/docupload/*</url-pattern>

after creating folder structure and namspace added - I changed the URL pattern as above mentioned one. But it's not working.


Solution

  • If you simply want to bypass a specific URL, you can use excludePattern in your struts.xml as below

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