Spring mvc 的多表单验证错误处理
public ModelAndView index(@ModelAttribute("registerSMGMethod1Step1Form") RegisterSMGMethod1Step1Form registerSMGMethod1Step1Form, BindingResult bindingResult1,@ModelAttribute("registerSMGMethod2Step1Form") RegisterSMGMethod2Step1Form registerSMGMethod2Step1Form,BindingResult bindingResult2,ModelAndView model, HttpServletRequest request) { model.setViewName("customer/smg-step1"); //处理method1_bingSMG foward过来的bindingResult. if(request.getAttribute("bindingResult")!=null){ String userType= (String)request.getAttribute("userType"); List<ObjectError> allerrors=(((BindingResult)request.getAttribute("bindingResult")).getAllErrors()); for(int idx=0;idx<allerrors.size();idx++){ if("SMGMethod1".equals(userType)){ bindingResult1.addError(allerrors.get(idx)); }else if("SMGMethod2".equals(userType)){ bindingResult2.addError(allerrors.get(idx)); } } }
相关推荐
yupi0 2020-10-10
spring 2020-08-18
编程点滴 2020-07-29
幸运小侯子 2020-07-05
itjavashuai 2020-07-04
qingjiuquan 2020-06-29
shushan 2020-06-25
小鱿鱼 2020-06-22
咻pur慢 2020-06-18
melonjj 2020-06-17
qingjiuquan 2020-06-13
neweastsun 2020-06-05
小鱿鱼 2020-06-05
mxcsdn 2020-05-31
吾日五省我身 2020-05-27
牧场SZShepherd 2020-05-27
sweetgirl0 2020-05-14