My interceptor (validation) is not getting called before or after the action. Any ideas how to get it work ?
Note : Everytime the default interceptor is being called.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default,json-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
<result-type name="json" class="org.apache.struts2.json.JSONResult" />
</result-types>
<interceptors>
<interceptor name="validation" class="ValidatorBaseAction"/>
<interceptor-stack name="default">
<interceptor-ref name="logger"/>
</interceptor-stack>
<interceptor-stack name="validationStack">
<interceptor-ref name="validation"/>
<interceptor-ref name="default"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="default" />
<action
name="viewRequest"
class="ViewAction"
method="execute">
<interceptor-ref name="validationStack" />
<result name="input" type="redirectAction">explore</result>
<result name="success" type="redirect">/showRequest.do?${explorerParameters}</result>
</action>
</package>
</struts>
Main problem:
class
both for Actions and Interceptors must specify the FQCN, not only the name. Then change it to something like:and also change your action to
Side problems:
ValidatorBaseAction
if it is anInterceptor
, call itValidatorBaseInterceptor
. And ensure there is nothing of an Action inside it;Polishing:
json-default
already extendsstruts-default
, so thisis equivalent to this
that is cleaner;
Since you extends json-default, you don't need to redefine the JSON result, then remove
that is useless.
Try always to prefer
redirectAction
result when redirecting to an Action, and useredirect
result only when redirecting to other resources or external URLs