我并沒(méi)有轉(zhuǎn)換result類型,但在返回result時(shí),報(bào)類型強(qiáng)轉(zhuǎn)錯(cuò)誤。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;
2017-09-08
已經(jīng)解決了。是因?yàn)橹霸贖ttpAspect類中的doAfterRunning方法中做了一個(gè)類型強(qiáng)轉(zhuǎn)