解决action中为模型赋值问题
不能直接为model赋值,没有改变栈顶的引用.
--------------------------------------
1.使用属性赋值(apache).
2.把新model压入栈顶.
ActionContext.getContext().getValueStack().push(s);
3.通过prepare拦截器 + paramsPrepareParamsStack组合,解决action的模型赋值问题
1.class SurveyAction ...{
public String designSurvey(){
...
}
public void prepareDesignSurvey(){
this.model = xxx ;
}
}
2.struts.xml配置文件中使用paramsPrepareParamsStack.
<interceptor-stack name="surveyparkStack">
<interceptor-ref name="loginInterceptor" />
<interceptor-ref name="paramsPrepareParamsStack" />
</interceptor-stack>
4.打开modelDriven的刷新模型属性.
struts.xml
<!-- 自定义拦截器栈 -->
<interceptor-stack name="surveyparkStack">
<interceptor-ref name="loginInterceptor" />
<interceptor-ref name="defaultStack">
<param name="modelDriven.refreshModelBeforeResult">true</param>
</interceptor-ref>
</interceptor-stack>