Bad action is handled via implementing UnknownHandler
. You can configure it in struts.xml
using a tag.
<bean type="com.opensymphony.xwork2.UnknownHandler" name="myhandler" class="org.struts.YourUnknownHandler"/>
The class org.struts.YourUnknownHandler
should implement UknownHandler
interface to handle the cases:
- when an action configuration is unknown
- when a result cannot be found for an action and result code
- when an action method cannot be found
Struts 2 can be also configured to handle unknown action or result, even without default-action-ref
tag it provides a configuration to process such requests. Generally you can use unknown-handler-stack
tag by the Struts2 xml configuration and reference handlers. You should check that what com.opensymphony.xwork2.UnknownHandler
is provided. If you are using a convention plugin it supplies by default convention
unknown handler, which could probably handle your action or result.
Read How to implement your unknown handler.
The method handleUnknownAction()
should return ActionConfig
. This config you should build yourself, you can use ActionConfig.Builder
. You can also build result separately, but if you have a global result
<global-results>
<result name="error">/WEB-INF/content/global-error-page.jsp</result>
</global-results>
you can find it in the runtime configuration and add to the newly baked action config.