我有以下三种REST API方法:春天开机:RequestMapping
@RequestMapping(value = "/{name1}", method = RequestMethod.GET)
public Object retrieve(@PathVariable String name1) throws UnsupportedEncodingException {
return configService.getConfig("frontend", name1);
}
@RequestMapping(value = "/{name1}/{name2}", method = RequestMethod.GET)
public Object retrieve(@PathVariable String name1, @PathVariable String name2) throws UnsupportedEncodingException {
return configService.getConfig("frontend", name1, name2);
}
@RequestMapping(value = "/{name1}/{name2}/{name3}", method = RequestMethod.GET)
public Object retrieve(@PathVariable String name1, @PathVariable String name2, @PathVariable String name3) {
return configService.getConfig("frontend", name1, name2,name3);
}
getConfig方法被配置为接受多个参数,如:
public Object getConfig(String... names) {
我的问题是:是否有可能实现上述RequestMapping只使用一个方法/ RequestMapping?
谢谢。
只是备案,这是一个Spring MVC的问题。春季启动更多的是一个包装 - 对所有春天的东西autoconfig –