This is working
@PostMapping(value="/foo", params={"add"})
public String add(@ModelAttribute Foo foo) {
return "foo";
}
@PostMapping(value="/foo", params={"delete"})
public String delete(@ModelAttribute Foo foo) {
return "foo";
}
Why is this one NOT working ?
@PostMapping("/foo")
public String add(@ModelAttribute Foo foo, @RequestParam String add) {
return "foo";
}
@PostMapping("/foo")
public String delete(@ModelAttribute Foo foo, @RequestParam String delete) {
return "foo";
}
With @PostMapping, I get following error message.
Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'webController' method
Why am I getting ErrorMessage when using @RequestParam ?
@PostMappingi.e.params={"...."}. The handler to be invoked will be resolved purely by its mapping and not by reference to any method args.@PostMapping("/foo")mapping for two methods. Java method name does not play any role here. Please read documentation to learn how to map requests to controller properly: docs.spring.io/spring/docs/current/spring-framework-reference/…@PostMappingfor delete method to@DeleteMapping