Question

I am having the opposite problem of the fellow in this question: Struts 2: excluding method from validation from just the defaultStack interceptor

The above question involved all methods being excluded, my issue is that no methods are being excluded!

I'm trying to get my authenticationInterceptor to ignore the showLogin method of my LoginAction:

<interceptors>
    <interceptor name="authorizationInterceptor" class="org.companyname.struts.interceptor.AuthorizationInterceptor"/>
    <interceptor-stack name="appDefault">
        <interceptor-ref name="authorizationInterceptor"/>
        <interceptor-ref name="defaultStack">
            <param name="exception.logEnabled">true</param>
            <param name="exception.logLevel">ERROR</param>
        </interceptor-ref>              
    </interceptor-stack>
</interceptors>
<default-interceptor-ref name="appDefault" />

<action name="loginInitial" class="org.companyname.struts.action.LoginAction" method="showLogin">
    <interceptor-ref name="appDefault">
        <param name="authorizationInterceptor.excludeMethods">showLogin</param>             
    </interceptor-ref>
    <result name="success">/login.jsp</result>                      
</action>

However, each time I forward to loginInitial, the interceptor grabs it, even though my showLogin method is being excluded.

I've checked for naming issues, and have tried putting several different values in the interceptor-ref within the action, and nothing seems to work.

What's the proper way to skip the authorizationInterceptor when I forward to loginIntial?

Was it helpful?

Solution

I believe my issue is the type of interceptor I'm using, the AbstractInterceptor. So, I just use different interceptor stacks on the actions I don't want intercepted:

<interceptor-stack name="appDefaultWithAuth">               
    <interceptor-ref name="defaultStack">
        <param name="exception.logEnabled">true</param>
        <param name="exception.logLevel">ERROR</param>
    </interceptor-ref>              
    <interceptor-ref name="authorizationInterceptor"/>
</interceptor-stack>            

<interceptor-stack name="appDefaultNoAuth">             
    <interceptor-ref name="defaultStack">
        <param name="exception.logEnabled">true</param>
        <param name="exception.logLevel">ERROR</param>
    </interceptor-ref>                  
</interceptor-stack>

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

<action name="loginInitial" class="org.company.struts.action.LoginAction" method="showLogin">
    <interceptor-ref name="appDefaultNoAuth"/>              
    <result name="success">/login.jsp</result>                      
</action>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top