You can narrow the primary mapping by specifying a list of consumable media types. The request will be matched only if the Content-Type request header matches the specified media type. For example:@Controller @RequestMapping(value = "/pets", method = RequestMethod.POST, consumes="application/json") public void addPet(@RequestBody Pet pet, Model model) { // implementation omitted }这个解释是什么意思呢??大体是消费指定的contentType类型,????
http://localhost:8080/abc/
这样的路径访问index.jsp了
@RequestMapping(value = "/pets", method = RequestMethod.POST, consumes="application/json")
public void addPet(@RequestBody Pet pet, Model model) {
// implementation omitted
}这个解释是什么意思呢??大体是消费指定的contentType类型,????
接受POST类型的请求,不接收GET类型的请求,如果不指定method,那么POST和GET都是可以接受的
@RequestBody 表示返回类型为JSON
@RequestBody 表示接受的参数是json类型。 它会自动帮你转换成Pet对象
@ResponseBody 表示返回类型为JSON