I want to know if it's possible to map the same URL to different methods in the RestController
class, based only in the request body. For example:
@RequestMapping(value="/delete", method=RequestMethod.POST )
public void delete(@RequestBody String id) {
//do something
}
@RequestMapping(value="/delete", method=RequestMethod.POST )
public void delete(@RequestBody Book book) {
//do something
}
The request body will always be a JSON payload. if it's {"id":"foo"}
I want the first method to be called. If the request body is:
{
"title":"Spring Guide",
"author":"John Doe"
}
I want the second method to be called. Is this possible?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…