标签:int 技术分享 font 结合 str err post请求 输出 ppi
@GetMapping("/demo/{id}") public void demo(@PathVariable(name = "id") String id, @RequestParam(name = "name") String name) { System.out.println("id="+id); System.out.println("name="+name); }
输出结果:
id=123
name=suki_rong
因为是POST请求,这里用Postman的截图结合代码说明
对应的java代码:
@PostMapping(path = "/demo1") public void demo1(@RequestBody Person person) { System.out.println(person.toString()); }
@PostMapping(path = "/demo1") public void demo1(@RequestBody Map<String, String> person) { System.out.println(person.get("name")); }
输出结果: suki_rong
@PostMapping(path = "/demo2") public void demo2(Person person) { System.out.println(person.toString()); }
SpringBoot Controller接收参数的几种常用方
标签:int 技术分享 font 结合 str err post请求 输出 ppi
原文地址:https://www.cnblogs.com/dand/p/10177914.html