You define interceptor in struts.xml
<interceptors>
<interceptor name="authentication" class="com.onepd.struts2.lesson.action.Authentication"/>
<interceptor-stack name="secureStack">
<interceptor-ref name="authentication"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
implements Interceptor in say Authentication class, method intercept()
will do all job.
or set
<global-results>
<result name="error" type="redirectAction">
...
</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
to process exceptions.
-----
Struts 2 tutorial
http://www.onepd.com