我有以下三種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 –