1.、关于下面这种方式呢,不建议使用,因为用了下面的,其实就和postman没区别了
2、正确的使用方式
2.1、Post请求
2.1.1、@RequestBody
不写的话,按照下面的正常调用就行了,但是如果写上了里面参数使用了required=true,一定不能让DTO对象为null,否则就会报错org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing 或者将它设置为required=false
@PostMapping(“addData”)
public String addData(@RequestBody(required = false) DataDTO dataDTO){
}
1
2
3
4
5
POST http://localhost.admin/addData
Accept: /
Cache-Control: no-cache
Content-Type: application/json; charset=UTF-8
Cookie: JSESSIONID=e1fd90bf-1148-4368-9fe9-018dcaf1aa0d
#请求参数,注意这里要空一样,否则就不会调用成功,因为如果和上面的参数紧挨着,就会被认为是参数的一种
{“typeKey”:“country”,“d