@RestController
@RequestMapping("/sys-user")
public class SysUserController {
@Autowired
private ISysUserService sysUserService;
@PostMapping("/getUser/{id}")
public SysUser getUser(@PathVariable("id")String id){
System.out.println(id);
SysUser u = sysUserService.getById(id);
u.setA1("111");
return u;
}
@PostMapping("/getUser1")
public SysUser getUser1(@RequestParam("id")String id){
System.out.println(id);
SysUser u = sysUserService.getById(id);
u.setA1("111");
return u;
}
@PostMapping("/getUser2")
public SysUser getUser2(@RequestBody String str){
System.out.println(str);
SysUser model = JSON.parseObject(str, SysUser.class);
SysUser u = sysUserService.getById(model.getUserId());
u.setA1("111");
return u;
}
@PostMapping("/getUser3")
public SysUser getUser3(@ModelAttribute("ma") SysUser ma){
SysUser u = sysUserService.getById(ma.getUserId());
u.setA1("111");
return u;
}
}
PathVariable的请求:
RequestParam的请求:
RequestBody的请求:
ModelAttribute的请求:
标签:PathVariable,RequestParam,public,RequestBody,sysUserService,getById,111,SysUser, From: https://blog.51cto.com/u_14816966/5722072