There are two ways to enable interceptors in struts.xml
First:
1) If you write any interceptors in another XML file, and you want to use these interceptors in the struts.xml file, you must include this file in struts.xml
For example: consider other.xml file is file.xml and you want to include in struts.xml like this
in struts.xml you need to write
<struts> <include file="file.xml"></include> <package name="posts" namespace="/posts" extends="struts-default,json-default"> <action name="question/ask" class="someclass.QuestionAction"> <interceptor-ref name="myStack"></interceptor-ref> <result name="success">/WEB-INF/jsp/post_question.jsp</result> <result name="input">/WEB-INF/jsp/post_question.jsp</result> </action> </package> </struts>
Second Way: You have to include interceptors in struts.xml and specify a name in your action class, then it will work correctly like this.
<package name="default" extends="struts-default"> <interceptors> <interceptor name="timer" class=".."/> <interceptor name="logger" class=".."/> <interceptor-stack name="myStack"> <interceptor-ref name="timer"/> <interceptor-ref name="logger"/> </interceptor-stack> </interceptors> <action name="login" class="tutuorial.Login"> <interceptor-ref name="myStack"/> <result name="input">login.jsp</result> <result name="success" type="redirect-action">/secure/home</result> </action> </package>
I also give two links, refer to these links, one of which, for example, I refer only to these links. The concept of full interceptors . Base interceptors
Raki
source share