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 {
文章来源:https://www.toymoban.com/news/detail-437912.html
@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文章来源地址https://www.toymoban.com/news/detail-437912.html
到了这里,关于postman发送json请求的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!