当返回result前对业务对象修改了,但是值栈中对应的对象依然是之前的就值,若想在返回result之前刷新值栈中业务对象各个属性的根对象,需在该action中配置如下参数:
[html] view plaincopyprint?
<action name="studentAction"
class="com.amouse.student.action.StudentAction">
<interceptor-ref name="defaultStack">
<!-- 渲染页面前刷新model在ValueStack的root的引用 -->
[b] <param name="modelDriven.refreshModelBeforeResult">
[u]true [/u]
</param> [/b]
</interceptor-ref>
<result name="main">/pages/student/student.jsp</result>
<result name="login">/pages/student/login.jsp</result>
<result name="success">/pages/student/studentInfo.jsp</result>
</action>
[html] view plaincopyprint?
<action name="studentAction"
class="com.amouse.student.action.StudentAction">
<interceptor-ref name="defaultStack">
<!-- 渲染页面前刷新model在ValueStack的root的引用 -->
[b] <param name="modelDriven.refreshModelBeforeResult">
[u]true [/u]
</param> [/b]
</interceptor-ref>
<result name="main">/pages/student/student.jsp</result>
<result name="login">/pages/student/login.jsp</result>
<result name="success">/pages/student/studentInfo.jsp</result>
</action>
本文详细介绍了在Spring MVC中如何在返回result前刷新ValueStack中业务对象各个属性的根对象,通过配置action参数实现渲染页面前刷新model在ValueStack的root的引用,确保业务对象最新状态。

被折叠的 条评论
为什么被折叠?



