Student.java
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
//@Component
public class Student {
@JsonProperty(“stuname”)
private String name;
@JsonProperty(“stuage”)
private int age;
}
StudentController.java
@Controller
public class StudentController {
@RequestMapping(value = "/aa", headers = "content-type=application/json")
@ResponseBody
public Student show(@RequestBody Student student){
return student ;
}
}
最终send后可以在responsebody得到发送的json数据(如果不用@JsonProperty,则json的key需要和Student对象的属性名相同)
@Control
版权归原作者 murenyangdaren 所有, 如有侵权,请联系我们删除。