tags:

views:

27

answers:

1

hello,

i have done some pages with Struts 2.(J2EE project) All was ok until i try to add an interceptor.

It seems that the Interceptor delete all properties of my Class Action and Parameters send by the jsp with url like: action?param=xxx

here is the interceptor:

public class SessionInterceptor extends AbstractInterceptor{    
    @Override
    public String intercept(ActionInvocation invocation) throws Exception {

        return invocation.invoke();     
}

here is the struts.xml:

    <action name="movefc_ShowFjt" class="struts2.ShowFjtAction" method="movefc">

        <interceptor-ref name="sessionInterceptor"></interceptor-ref>
        <result name="input" type="dispatcher">jsp/showFjt.jsp</result>
        <result name="success" type="dispatcher">jsp/showFjt.jsp</result> 
    </action>    

in the class action,

public class ShowFjtAction extends ActionSupport {


private String param;
private Personne p;

param property never receive value from the jsp (it is ok when interceptor is off). Worse, other properties in Class action seems to be erased. Is that an normal effect of the return invocation.invoke(); of the interceptor ? Is there anything i can do to fix that ?

A: 

y defining your own interceptor are you causing all of the default interceptors to be discarded?

Should you perhaps be defining an interceptor stack which includes your interceptor and the default stack?

<package name="default" extends="struts-default">
   <interceptors>
        <interceptor name="sessionInterceptor" class="SessionInterceptor"/>
        <interceptor-stack name="myStack">
           <interceptor-ref name="sessionInterceptor"/>
        </interceptor-stack>
    </interceptors>

<action name="movefc_ShowFjt"
     class="struts2.ShowFjtAction">
         <interceptor-ref name="myStack"/>
         <result name="input" type="dispatcher">jsp/showFjt.jsp</result>
         <result name="success" type="dispatcher">jsp/showFjt.jsp</result> 
</action>
Alex
A first Test shows that your are right. I was believing that the <interceptor-stack> in Struts.xml was optional but, in fact, it seems that you have to use it.
cyberfred