Spring Security targetUrlParameter does not redirect

前端 未结 6 1562
长情又很酷
长情又很酷 2020-12-19 12:37

I\'m trying to redirect the user back to the page where they clicked the login link. (Pages are read-only for non-authenticated users, but writable for logged in users.) How

6条回答
  •  渐次进展
    2020-12-19 12:52

    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 read-only page, save the path to the 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 page that they last visited.

提交回复
热议问题