I can't seem to find any sort of information on how to configure both Jersey and Struts 2 in one app. I have the following web.xml:
<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/ajax/*</url-pattern>
</servlet-mapping>
<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>
I am using Struts 2 annotation configuration for action classes, results, etc. However, I still have a struts.xml in the src/
that gets put into the WEB-INF/classes to configure a few things. One of them is an option not easily found on google about telling Struts to ignore one or more URL patterns. So given that I want ALL requests EXCEPT any url with ajax/*
in it, to Struts 2, I have the above and added the ajax/*
pattern to the struts.xml like so:
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.convention.classes.reload" value="true" />
<constant name="struts.enable.SlashesInActionNames" value="true" />
<constant name="struts.action.excludePattern" value="/ajax/*?" />
<package name="default" extends="struts-default" namespace="/">
<action name="index">
<result>/index.jsp</result>
</action>
</package>
</struts>
As you see, the excludePattern
is used to tell Struts what to ignore. Still, I can't get any of my Jersey requests to get through to the resources. They are loading..I see them being round in the log output. The only error I get is that Struts has no action mapped to /ajax/somePath
.
So if anyone has configured Struts2 and Jersey, I'd be much appreciated in helping me resolve how to make them work together so that one (or a few url paths) make it through to Jersey, the rest go to Struts2.