在使用postman测试GET请求时,
大多是直接在url内传递参数,类似于这样
http://localhost:8080/Accounts/AccountsByName?account_name=chen
而我不想在url中暴露参数,于是就查了很多文章,发现他们都是用url传递参数
所幸自己后来瞎猫碰死耗摸索清楚了,在此做个总结.
@RequestBody简介:
这个注解用于读取请求的body内的数据,进行解析,然后把数据绑定到对象上.
可用于GET和POST请求.
举个例子
1)我的controller:
//根据账户名查询用户
@RequestMapping(value = "Accounts/AccountsByName",method = RequestMethod.GET)
@ResponseBody
public String accountBN(@RequestBody Account account){
String name = account.getAccount_name();
log.