public class StudentAction extends BaseAction implements ModelDriven<StudentBO>, Preparable { private static final long serialVersionUID = 1L; @Resource private StudentService studentService; @Override public StudentBO getModel() { return student; } @Override public void prepare() throws Exception { student = new StudentBO(); } public StudentService getStudentService() { return studentService; } public void setStudentService(StudentService studentService) { this.studentService = studentService; } }
当返回result前对业务对象修改了,但是值栈中对应的对象依然是之前的就值,若想在返回result之前刷新值栈中业务对象各个属性的根对象,需在该action中配置如下参数:
<action name="studentAction" class="com.amouse.student.action.StudentAction"> <interceptor-ref name="defaultStack"> <!-- 渲染页面前刷新model在ValueStack的root的引用 --> <param name="modelDriven.refreshModelBeforeResult"> true </param> </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>