How to use servlets
together with Struts2
?
I assume you want to know how to use a servlet in conjunction with Struts2 when you have mapped everything to the Struts2 filter.
You can use the following in your struts.xml
:
<constant name="struts.action.excludePattern" value="/YourServlet"/>
You can exclude multiple patterns by separating them with a comma, such as:
<constant name="struts.action.excludePattern" value="/YourServlet,/YourOtherServlet"/>
More Information
There are three ways to resolve this problem:
add constant tag in struts.xml
<constant name="struts.action.excludePattern" value="/YourServlet,/YourOtherServlet"/>
add suffix in servlet configuration in web.xml
<servlet-mapping>
<servlet-name>Authcode</servlet-name>
<url-pattern>/authcode.servlet</url-pattern>
</servlet-mapping>
Because in struts 2, it will only intercept all the request end with .action, if this request do not have any suffix, it will automatically add it. When we make our servlet url-pattern have a suffix, then struts 2 will not intercept it anymore.
implement a user-defined filter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With