How to manage/store request parameters for subsequent request in spring mvc?

让人想犯罪 __ 提交于 2020-01-30 11:52:26

问题


I frequently use scenario as:

  1. List users ( on ajax call )
    On a search page, after search button click with some search criteria., I have list of Users in jQuery datatable
  2. Click to Edit User
    In datatable I click to edit user from list, I redirects to a form for User update populated with user fields for updating purpose.
  3. Update User
    After successfully updating User, redirect to Search Page with search criteria from 1st Request.

Currently I'm passing Search criteria parameters when I click to edit user in 2nd request, store them as hidden fields in update user form, after update button click 3rd request pass them to controller. If successful Update again pass them to Search Page to know previous search criteria.

Any other idea to Know Previous Search Criteria ?
Is using session is good solution or should I continue with my solution ?

Update
Now request parameters are encapsulate in bean.


回答1:


No don't use a session for this, will be confusing if you have multiple browser tabs open. You should just use Javascript code, if you need to use cookies so be it but you shouldn't even need that. This sort of stuff you will have less trouble if you put your front-end developer hat on instead of your backend.



来源:https://stackoverflow.com/questions/48355807/how-to-manage-store-request-parameters-for-subsequent-request-in-spring-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!