1 the @ modelAttribute receive parameter is used in the
1 post request, and paramterType is query, in the swagger-ui document. I want to get
of type body.2, code
@ ApiModel ("user description")
public class User {
@ApiModelProperty(value="",required=true)
private String name;
@ApiModelProperty(value="",required=true)
private Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
@Override
public String toString() {
return "User [name=" + name + ", age=" + age + "]";
}
}
@ ApiOperation (value = "GET BODY update data")
@RequestMapping(value = "model/{id}", method = RequestMethod.GET)
public ResponseEntity<ModelMap> modelResource(@ApiParam(value="",required=true) @ModelAttribute User user,
@ApiParam(name = "id", value = "", required = true) @PathVariable String id){
System.out.println(user);
ModelMap modelMap = new ModelMap();
modelMap.put("status", HttpStatus.OK.value());
modelMap.put("timestamps",System.currentTimeMillis());
modelMap.put("msg", HttpStatus.OK.getReasonPhrase());
modelMap.put("user", user);
modelMap.put("apiversion", 2);
return ResponseEntity.status(HttpStatus.OK).body(modelMap);
}
effect
do not want to change the @ modelAttribute annotation, but get the parameter of type body