1

I need to update my model attribute inside a resource method. The thing is that, after update it, I'd need to set this new modified bean in the model, in order to get the right timestamp to do the next operation when some action method be called.

I have my bean with @SessionAttributes(ServletContextKeys.MY_BEAN) and @ModelAttribute(ServletContextKeys.MY_BEAN) anotations, so I get my bean from the session in the resource method, but after update it, I've no idea how to access the model in the resource phase or any other possible workarround to solve this issue.

 @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);
    }
4

0 回答 0