user1260893
user1260893

Reputation: 459

One Spring controller reusable to different views

I'm developing a web site in which you can login from almost every page. The login action is the same to every page but always it must return to the page from which the action has been launched. My idea is to manage all the login request with the same Spring controller (make it reusable) and depends on the page that called it, forward to it.

I don't know if it is possible or if there is another way to accomplish my requirements without having to "copy" the same action on each controller.

Upvotes: 0

Views: 142

Answers (1)

Alex Gitelman
Alex Gitelman

Reputation: 24732

For each page, generate login link URL in such way that it includes return page URL. Then your login controller will know where to redirect after successful login.

For example on MyPage.html, login link will be http://server/login.do?returnURL=MyPage.html

Your controller will be attached to login.do and redirect at the end to returnURL.

Upvotes: 1

Related Questions