我在点击提交按钮时使用以下代码执行,我收到以下错误并且不确定错误在哪里,有人可以在这里提出建议吗?
private ModelAndView save(HttpServletRequest request,
HttpServletResponse response) throws Exception {
try {
List<FundsProductPurpose> fppList = funderRepository.getFundsList();
FundsProductPurpose fpp = fppList.get(0);
return doMapping("result", "Funder details added successfully",
request);
} catch (Exception e) {
e.printStackTrace();
return doMapping("result", "Unable to add funder details", request);
}
}
我得到的错误是,
java.lang.ClassCastException: com.mmf.model.FundsDetails cannot be cast to com.mmf.model.FundsProductPurpose
at com.mmf.controllers.SaveFundsController.save(com.mmf.controllers.SaveFundsController:98)
答案 0 :(得分:0)
在发布的代码中,您在FundsDetails
创建了funderRepository
,但您从FudsDetails
获得了fundRepository
。您应该使用FundsDetails
fundRepository
FundsDetails fundsDetails = new FundsDetails();
fundsDetails.setIdStaticFunder(funderId);
.....
fundRepository.createFund(fundsDetails);// Use fundRepository