如何在spring mvc中管理/存储后续请求的请求参数? [英] How to manage/store request parameters for subsequent request in spring mvc?

查看:109
本文介绍了如何在spring mvc中管理/存储后续请求的请求参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常使用场景:


  1. 列出用户(在ajax调用上)

    在搜索页面上,点击搜索按钮后点击一些搜索条件。,我有jQuery数据表中的用户列表

  2. 点击编辑用户

    在数据表I中单击以从列表中编辑用户,我重定向到用户更新的表单,其中填充了用户字段以进行更新。

  3. 更新用户

    成功更新用户后,重定向到从第一次请求搜索搜索条件

  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.

目前我是当我点击编辑第二次请求中的用户时,传递搜索条件参数,将其存储为更新用户表单中的隐藏字段,更新按钮后单击第3次请求将它们传递给控制器​​。如果成功更新,请再次将其传递给搜索页以了解以前的搜索条件

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.

了解以前的搜索条件 strong>?

使用会话是一个很好的解决方案还是我应该继续使用我的解决方案?

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

更新

现在请求参数封装在 bean 中。

推荐答案

不要不使用会话,如果您打开多个浏览器选项卡,将会感到困惑。您应该只使用Javascript代码,如果您需要使用cookie,那么就是它,但您甚至不需要它。如果你把前端开发人员的帽子放在后端而不是你的后端,那么你可以减少这种麻烦。

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.

这篇关于如何在spring mvc中管理/存储后续请求的请求参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆