数据转换和校验
Web交互层
public class UserInfoimplements Serializable {
private String userId;
@NotEmpty
private String userName;
@NotEmpty
private String password;
}@RequestMapping(value = "/body", method = RequestMethod.POST)
public
@ResponseMessage
@Valid
UserInfo validateRequestBody(@RequestBody @Valid UserInfo userInfo, BindingResult result) {
result.getAllErrors().stream().forEach(System.out::println);
return userInfo;
}编码式校验
Last updated