In specific
I want to do Multiple URL Mapping (in other words aliases) in spring boot
In Detail
In my spring boot a
Take a look at this example.
The best way to map url is to do it in the controller with annotations.
Basically:
@RestController
public class HelloController {
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
}
IMHO The best practice is to use one mapping for the controller and one for every method:
@RestController
@RequestMapping("/Hello")
public class HelloController {
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
@RequestMapping("/otherMapping")
public String otherMapping() {
return "Greetings from Spring Boot!";
}
}
That way urls will look like: localhost:8080/Hello and localhost:8080/Hello/otherMapping
Edit:
For multiple mappings you can use:
@RequestMapping({ "/home", "/contact" })