The following general solution can be used with a regular login, Spring social login, or most other Spring security filters.
In your Spring MVC controller, when loading a read-only page, save the path to the page in the session if the user is not logged in. In the XML configuration, set the default destination URL. For instance:
In your MVC Spring controller, the redirect method should read the path from the session and return redirect:<my_saved_page_path> .
So, after the user logs in, they will be sent to the /redirect page, which will quickly redirect them to the page that they visited the last time.
source share