Solve the problem of assigning model value in action

Solve the problem of assigning model value in action

You cannot assign a value directly to the model without changing the reference at the top of the stack.

--------------------------------------

1. Use attribute assignment (apache).

2. Push the new model to the top of the stack.

ActionContext.getContext().getValueStack().push(s);

3. Solve the model assignment problem of action through the combination of prepare interceptor + paramsPrepareParamsStack

1.class SurveyAction ...{

public String designSurvey(){

...

}

 

public void prepareDesignSurvey(){

this.model = xxx ;

}

}

 

2. Use paramsPrepareParamsStack in the struts.xml configuration file.

<interceptor-stack name="surveyparkStack">

<interceptor-ref name="loginInterceptor" />

<interceptor-ref name="paramsPrepareParamsStack" />

</interceptor-stack>

4. Open the refresh model properties of modelDriven.

struts.xml

<!-- Custom interceptor stack -->

<interceptor-stack name="surveyparkStack">

<interceptor-ref name="loginInterceptor" />

<interceptor-ref name="defaultStack">

<param name="modelDriven.refreshModelBeforeResult">true</param>

</interceptor-ref>

</interceptor-stack>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326683183&siteId=291194637