在资源阶段Spring MVC期间设置模型属性

时间:2013-07-01 07:30:54

标签: spring-mvc modelattribute

我需要在资源方法中更新我的模型属性。更新之后,我需要在模型中设置这个新的修改后的bean,以便在调用某个操作方法时获得正确的时间戳来执行下一个操作。

我有我的豆子     @SessionAttributes(ServletContextKeys.MY_BEAN) 和     @ModelAttribute(ServletContextKeys.MY_BEAN)  anotations,所以我在资源方法中从会话中获取了我的bean,但在更新之后,我不知道如何在资源阶段或任何其他可能的工作环境中访问模型来解决这个问题。

 @ResourceMapping(ServletContextKeys.MY_RESOURCE_METHOD)
 public final void updateDoc(){
    MyBean myBean = getBeanFromSession();
    MyBean myNewBean = myService.updateDocs(myBean); //This mehod will change the timestamp and return the updated bean

    //Now I'd like to set the bean in the model. How could I access it?
    model.addAttribute(ServletContextKeys.MY_BEAN, myNewBean);
    }

0 个答案:

没有答案
相关问题