Spring Security redirect to previous page after successful login

前端 未结 9 1184
孤独总比滥情好
孤独总比滥情好 2020-11-27 10:09

I know this question has been asked before, however I\'m facing a particular issue here.

I use spring security 3.1.3.

I have 3 possible login cases in my web

9条回答
  •  我在风中等你
    2020-11-27 10:54

    The following generic solution can be used with regular login, a Spring Social login, or most other Spring Security filters.

    In your Spring MVC controller, when loading the product page, save the path to the product page in the session if user has not been logged in. In XML config, set the default target url. For example:

    In your Spring MVC controller, the redirect method should read out the path from the session and return redirect:.

    So, after user logs in, they'll be sent to /redirect page, which will promptly redirect them back to the product page that they last visited.

提交回复
热议问题