@PathVariable,@RequestParam,@RequestBody以及无注解比较

如下: 

//    注解 				支持的类型 	支持的请求类型 				支持的Content-Type 					请求示例
//
//    @PathVariable 	url 	GET 					所有 									/test/{id}
//    @RequestParam 	url 	GET 					所有 									/test?id=1
//    @RequestBody 		Body 	POST/PUT/DELETE/PATCH 	json 								{"id":1}
//    					Body 	POST/PUT/DELETE/PATCH 	form-data或x-www.form-urlencoded 	id:1
    @PostMapping("/save")
    public ResponseMsg save(Test test) {
    	System.out.println("jsonStr:" + test.toString());
    	return new ResponseMsg();
    }

猜你喜欢

转载自blog.csdn.net/xingsfdz/article/details/116651584