List of usage examples for org.springframework.web.bind ServletRequestDataBinder getBindingResult
public BindingResult getBindingResult()
From source file:org.springframework.web.servlet.mvc.generic.GenericFormController.java
/** * This implementation calls {@link #showForm} in case of errors, * and delegates to {@link #onSubmit}'s variant else. * <p>This can only be overridden to check for an action that should be executed * without respect to binding errors, like a cancel action. To just handle successful * submissions without binding errors, override the {@link #onSubmit} method. * @see #showForm/*from w w w.ja v a 2s.co m*/ * @see #onSubmit */ protected ModelAndView processFormSubmission(HttpServletRequest request) throws Exception { T formObject = formBackingObject(request); ServletRequestDataBinder binder = createBinder(request, formObject); binder.bind(request); BindingResult bindingResult = binder.getBindingResult(); onBind(request, formObject, bindingResult); return processFormSubmission(request, formObject, bindingResult); }
From source file:org.springframework.web.servlet.mvc.multiaction.MultiActionController.java
/** * Bind request parameters onto the given command bean * @param request request from which parameters will be bound * @param command command object, that must be a JavaBean * @throws Exception in case of invalid state or arguments *///from w ww. j av a2 s .com protected void bind(HttpServletRequest request, Object command) throws Exception { logger.debug("Binding request parameters onto MultiActionController command"); ServletRequestDataBinder binder = createBinder(request, command); binder.bind(request); if (this.validators != null) { for (Validator validator : this.validators) { if (validator.supports(command.getClass())) { ValidationUtils.invokeValidator(validator, command, binder.getBindingResult()); } } } binder.closeNoCatch(); }