PostMan 请求路径 url
post请求Content-Type为application/json

post的请求方式
在Body写入json格式的参数,主要红线的地方及标注信息:
== 注意:返回的json数据格式一定要正确否则获取的数据为空==
填写Body中的json数据格式如下
{
"userName": "admin",
"passWord": "admin2018"
}```

在 java 后台获取参数,使用== @ModelAttribute ==注解接收的数据为空字符串,需要修改为== @RequestBody ==注解接收数据

### get的请求方式
get请求Content-Type可以不选择,在Body中raw后可以不选择json,直接使用Text

在 java 后台获取参数,使用== @ModelAttribute ==注解接收的数据为空字符串,需要修改为== @RequestBody ==注解接收数据

JSONObject转换为字符串并存放至Map中,便于service层接收数据,当然直接使用字符串也可以实现
网友评论