Spring MVC pass same object between controller

前端 未结 2 1699
栀梦
栀梦 2020-12-16 02:29

In Spring MVC how do I pass an object between two controller methods? I have an update form and an updateController. In the controller I have 2 methods, one for fetching the

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-16 02:47

    How can I make sure the same object is passed by view. I do not want to add the object as sessionAttribute since a user might modify many employees in a session

    You could make a field in the object that is filled with a random number at the time of initial render and then store that object in the session. In the view you can map that field with a hidden input and now when user sends a request to edit action you can get that hidden field and fetch the original object from session by the number in the hidden field. That would resolve the multiple edits in different tabs conflict.

提交回复
热议问题