我用弹簧休息。
我想显示一个对象并保存它。
@RequestMapping(value = "/lodgers", method = RequestMethod.POST)
public LodgerInformation createLodger(@RequestBody @Valid final LodgerInformation lodgerDto) {
return lodgerService.save(lodgerDto);
}
public class LodgerInformation {
private long lodgerId;
private String firstName;
private String lastName;
private List<IdentityCardDto> identityCardDtoList;
...
}
public class IdentityCardDto {
private long identityCardId;
private IdentityCardTypeDto identityCardTypeDto;
private String value;
...
}
public class IdentityCardTypeDto {
private long identityCardTypeId;
private String identityCardType;
private Date expiration;
private boolean hasExpirationDate=false;
...
}
在 html 方面,我需要为名称使用什么结构?是否有一些库可以促进将值分配给 html 组件的过程,反之亦然
得到答案:
"{"timestamp":1436292452811,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"无法读取文档:无法识别令牌“firstName”:在 [Source: java.io.PushbackInputStream@3f7cf4ca; 处期待“null”、“true”、“false”或 NaN\n;行:1,列:11];嵌套异常是 com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'firstName': was expecting 'null', 'true', 'false' or NaN\n at [Source: java.io.PushbackInputStream@3f7cf4ca; 行:1,列:11]","path":"/lodgers"}"