Return to other link pages from the edit page

I am using Spring MVC (not WebFlow). I have a page setup for editing a specific object. This page can be called from many others. I am looking for best practice on how to return to the "referring" page after the edit page has been POSTED. That is, the best way to determine which page is called the edit page and return to this page.

I have my own ideas, but I am sure that many of you have already dealt with this and probably had better solutions.

+4
source share
2 answers

If you publish on your edit page, you can add a value to the published data that identifies the original page. This method allows you to determine the correct view to return to.

I would do this instead of redirecting to the linking page, because it allows you to make any configuration required by the source page before sending the user to the source page.

+1
source

You can save the path in the Referer header field, then you can return as follows: -

 @RequestMapping(...) public ... () { ... return "redirect:"+ request.getHeader("Referer"); } 

I have seen this approach several times.

0
source

Source: https://habr.com/ru/post/1337223/


All Articles