Struts exclude pattern with spring

1.5k views Asked by At

I did a lot of homework before coming here to the experts , appreciate any pointers on my question

I need to run a merged (not integrated) app that was basically combined version of struts2 and Spring and some base servlets. Was able to get the combined war file up without errors in tomcat. My intention is to based on url patterns route to appropriate framework (a well beaten problem :)

Let's call the single context as myctx

My situation:

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

And with

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

If I leave the url pattern as /* in the filter mapping, all the original struts2 actions are accessible but nothing is accessible from spring related

If I make the struts filter url-pattern as /myctx/.*?, noting is accessible from original struts component but spring url is accessible.

Appreciate any pointers here

If it matters using struts 2.3.16 and spring 3

Are there any other ways ? On springframework less url patterns to enumerate

Thanks a bunch in advance

-CJ

1

There are 1 answers

2
Roman C On BEST ANSWER

To use spring servlet separately from Struts 2 framework you should use the configuration settings in your struts.xml to exclude servlet from filter mapping.

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

The servlet mapping in web.xml (The DispatcherServlet):

<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/myctx/*</url-pattern>
</servlet-mapping>