struts2 global result not redirecting to action -


i have custom interceptor (transferinterceptor) checks function change within application. when changes, interceptor returns post-processing string (the result) containing global results name of action want redirect to. have results defined in global results of struts.xml file, not redirect specified action. have 'login' global result works fine, being called jsp with:

<s:a action="login.action">login</s:a> 

the struts.xml file:

<package name="default" extends="struts-default" namespace="/">     <interceptors>         <interceptor name="authenticationinterceptor" class="com.purchasing.utils.authenticationinterceptor" />         <interceptor name="transferinterceptor" class="com.purchasing.utils.transferinterceptor" />         <interceptor-stack name="securestack">             <interceptor-ref name="transferinterceptor" />             <interceptor-ref name="authenticationinterceptor" />             <interceptor-ref name="defaultstack" />         </interceptor-stack>     </interceptors>      <default-interceptor-ref name="securestack" />      <global-results>         <result name="login">login.jsp</result>         <result name="resulta" type="redirect">actiona</result>         <result name="resultb" type="redirect">actionb</result>     </global-results>      <action name="login" class="com.purchasing.actions.login">         <interceptor-ref name="defaultstack"></interceptor-ref>         <result name="success">welcome.jsp</result>         <result name="error">login.jsp</result>         <result name="input">login.jsp</result>     </action>      <action name="actiona" class="com.purchasing.actions.actiona">         <result name="success">actiona.jsp</result>         <result name="error">actiona.jsp</result>         <result name="input">actiona.jsp</result>     </action>         <action name="actionb" class="com.purchasing.actions.actionb">         <result name="success">actionb.jsp</result>         <result name="error">actionb.jsp</result>         <result name="input">actionb.jsp</result>     </action>                  </package> 

the transferinterceptor:

public string intercept(actioninvocation ai) throws exception {     string result = ai.invoke();      session = ai.getinvocationcontext().getsession();     fl = (functionline) session.get(constants.function_line);     function = fl.getfl_function();     last_function = (integer) session.get(constants.last_function);      if (function != last_function) {        session.put(constants.last_function, new integer(function));        switch (function) {               case 61: return "resulta";               case 62: return "resultb";        }        return "error";     }     else {        return result;     }  } 

any appreciated!

as per @lukasz comment :

if want redirect action use redirectaction result type instead of redirect used redirect static resources

it still won't work, because actionb & actiona never executes since go through same interceptor stack, returned redirectaction result & hence, it's kinda stuck in infinite loop.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -