Spring-MVC controller redirect to “previous” page?

后端 未结 7 1090
无人共我
无人共我 2021-01-31 18:34

Let\'s say I\'ve got a form for editing the properties of a Pony, and in my web application there are multiple places where you can choose to edit a Pony. For instance, in a li

7条回答
  •  轮回少年
    2021-01-31 19:15

    One option, of course, would be to open the edit form in a new window, so all the user has to do is close it and they're back where they were.

    There are a few places in my current application where I need to do something complicated, then pass the user to a form, and then have them return to the starting point. In those cases I store the starting point in the session before passing them off. That's probably overkill for what you're doing.

    Other options: 1) you can store the "Referer" header and use that, but that may not be dependable; not all browsers set that header. 2) you could have javascript on the confirmation page after the form submission that calls "history.go(-2)".

提交回复
热议问题