对于单参数方法, 一直喜欢用parameter方式。今天不知道为啥,就想用Json方式,然后无法直接传递。各种自我怀疑,然后尝试。 突然醒悟过来,Json方式是key/value模式,单参数String类型,没有key。必须记录一下脑残的实验 |
@PostMapping("/say") public String sayHello0(@RequestParam String name) { System.out.println("input value:" + name); return "hi " + name; }
@PostMapping("/hash") public String sayHello1(@RequestBody String name) { System.out.println("input value:" + name); return "hi " + name; }
@PostMapping("/json") public String sayHello2(@RequestBody JSONObject job) { System.out.println("input value:" + job.getString("name")); return "hi " + job.getString("name"); }
@PostMapping("/prop") public String sayHello2(@RequestBody Properties job) { System.out.println("input value:" + job.getProperty("name")); return "hi " + job.getProperty("name"); }
|