Permanently redirect endpoint path Spring Controller

Last modified date

Comments: 0



Over time, the endpoints on your spring server application will change. A particular path may need to be permanently changed.

For example and endpoint user needs to be permanently changed to account. But you may still need to support the old user endpoint for backward compatibility.

What is the easiest way to permanently redirect the user path to the account path, whilst still supporting the old path?

You can use the @RequestMapping annotation to map multiple paths to the same function in a Spring controller.


The @RequestMapping annotation is where you can specify the values of the path where Spring should direct requests:


The @RequestMapping annotation can take multiple path values. This will allow you to map multiple paths to the same function in a controller:

@RequestMapping(value={ "/user", "/account" })

Now all request not user and account will be directed to the same function in Spring.


Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.