请求数据
id:1
roleName:admin
roleDes:拥有admin权限
Controller几种处理方式
- 第一种
@ApiOperation("查询用户")
@PostMapping("/detailByParam")
public void detailByParam(@RequestParam (value = "id") Integer id,@RequestParam(value = "roleName") String roleName,@RequestParam(value = "roleDes") String roleDes) {
(">>>,roleName="+roleName+",roleDes="+roleDes);
}
- 1
- 2
- 3
- 4
- 5
打印信息:>>>id=1,roleName=admin,roleDes=拥有admin权限
- 第二种
@ApiOperation("查询用户")
@PostMapping("/detailByParam")
public void detailByParam(@RequestParam Map<String, String> params) {
(">>>id")+",roleName="+("roleName")+",roleDes="+("roleDes"));
}
- 1
- 2
- 3
- 4
- 5
打印信息:>>>id=1,roleName=admin,roleDes=拥有admin权限
- 第三种
@ApiOperation("查询用户")
@PostMapping("/detailByParam")
public void detailByParam(@RequestBody String params) {
(">>>"+params);
}
- 1
- 2
- 3
- 4
- 5
打印信息:>>>id=1&roleName=admin&roleDes=%E6%8B%A5%E6%9C%89admin%E6%9D%83%E9%99%90
- 第四种
@ApiOperation("查询用户")
@PostMapping("/detailByParam")
public void detailByParam(@RequestBody GetRoleParam getRoleParam) {
(">>>"+getRoleParam);
}
- 1
- 2
- 3
- 4
- 5
返回错误信息:“Content type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported”。