Is it possible to use multiple @RequestMapping annotations over a method?
Like :
@RequestMapping("/")
@RequestMapping("")
@RequestMapping("/welcome")
public String welcomeHandler(){
return "welcome";
}
@RequestMapping has a String[] value parameter, so you should be able to specify multiple values like this:
@RequestMapping(value={"", "/", "welcome"})
Doesn't need to. RequestMapping annotation supports wildcards and ant-style paths. Also looks like you just want a default view, so you can put
<mvc:view-controller path="/" view-name="welcome"/>
in your config file. That will forward all requests to the Root to the welcome view.
Right now with using Spring-Boot 2.0.4 - { } won't work.
@RequestMapping
still has String[] as a value parameter, so declaration looks like this:
@RequestMapping(value=["/","/index","/login","/home"], method = RequestMethod.GET)
** Update - Works With Spring-Boot 2.2**
@RequestMapping(value={"/","/index","/login","/home"}, method = RequestMethod.GET)