Spring-MVC controller redirect to “previous” page?

后端 未结 7 1088
无人共我
无人共我 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:17

    one other option would be to design your urls so they reveal the context of what you're doing, and by convention, would allow you to "know" where the start of an operation was.

    For example, you could have urls like so

    site/section1/pony/edit
    site/section1/pony/delete
    
    site/somewhere/else/entirely/pony/edit
    site/somewhere/else/entirely/pony/delete
    

    both those urls allow pony editing and deleting. To go back to the start for both of them, you'd simply go "up" 2 folders. This could be done via a javascript function that looks at the current url, and just goes up 2 folders, or you could figure it out on the server side 2, and do a redirect like that as well.

提交回复
热议问题