问题
I frequently use scenario as:
- 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 - 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. - 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