I have a Spring application where I declared my class like so:
@Controller
@RequestMapping(value = "/rest/api/datasources/", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
public class MetadataServiceController {
//Two separate methods:
@RequestMapping(value="{datasourceName}")
public Object getLatestApiMetadata(@PathVariable String datasource,
@RequestParam (required = false) String datasourceNum,
@RequestParam (defaultValue = "true") String dataFields,
@RequestParam ( required=false, defaultValue = "api") String visibility){
... //Implementation here
}
@RequestMapping(value="{apiVersion}")
public @ResponseBody List<DataSource> getAllMetadata(
@RequestHeader(value="sub-version", required=false, defaultValue="0.0") String minorVer,
@PathVariable String restApiVersion,
@RequestParam(required = false) String datasourceNum,
@RequestParam(defaultValue = "all") String visibility)
throws ObjectNotFoundException {
... //Implementation here
}
}
But when I try to reach one of these rest endpoints, I get an error saying: java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path
and it specifies those two methods as the issue. I was under the impression that if I change the request parameters, Spring would not complain about them being the same via this post: http://www.coderanch.com/t/598675/Spring/handling-HTTP-Request-parameters but clearly it still does. Would anyone have any suggestions on how to get around this? Thanks!