Search code examples
javaconfigurationstruts2interceptorinterceptorstack

How to exclude One action from default interceptor in Struts 2


I want to exclude login action from my default interceptor without putting it a diffrent package

<default-interceptor-ref name="loginStack"></default-interceptor-ref>

the action that i want to exclude is Login Action

<action name="loginUser" class="com.action.LoginAction" method="login">

Solution

  • You don't exclude actions from interceptors, you exclude interceptors from actions.

    Specifically, if you want to use the defaultStack for your login action and the loginStack for all the other actions, you do:

    <default-interceptor-ref name="loginStack"></default-interceptor-ref>
    
    ...
    
    <action name="loginUser" class="com.action.LoginAction" method="login">
        <interceptor-ref name="defaultStack" />
        <result>login.jsp</result>
    </action>