我并没有转换result类型,但在返回result时,报类型强转错误。java.lang.ClassCastException: com.example.girl.domain.Result cannot be cast to com.example.girl.domain.Girl
@PostMapping(value = "/addGirl")
public Result<Girl> girlAdd(@Valid Girl girl, BindingResult bindingResult) {
Result result = new Result();
if(bindingResult.hasErrors()) {
result.setCode("1");
result.setMsg(bindingResult.getFieldError().getDefaultMessage());
//result.setData(null);
} else {
girl.setCupSize(girl.getCupSize());
girl.setAge(girl.getAge());
result.setCode("0");
result.setMsg("添加成功");
result.setData(girlRepository.save(girl));
}
return result;