List of usage examples for org.springframework.beans TypeMismatchException getRequiredType
@Nullable
public Class<?> getRequiredType()
From source file:org.easyj.rest.controller.AbstractController.java
@ResponseStatus(value = HttpStatus.BAD_REQUEST) @ExceptionHandler(TypeMismatchException.class) public ModelAndView handleTypeMismatch(TypeMismatchException e) { BindingResult result = createBindingResult(getClass()); result.addError(new FieldError("param.bind", e.getRequiredType().getSimpleName(), e.getValue(), true, null, null, "error.param.bind.type")); return configMAV(null, result, "errors/badrequest"); }
From source file:org.openmrs.module.radiology.web.controller.PortletsController.java
/** * Handle all exceptions of type TypeMismatchException which occur in this class * // w w w . ja v a2 s. c o m * @param TypeMismatchException the thrown TypeMismatchException * @return model and view with exception information * @should populate model with exception text from message properties and invalid value if date * is expected but nut passed * @should should populate model with exception text */ @ExceptionHandler(TypeMismatchException.class) public ModelAndView handleTypeMismatchException(TypeMismatchException ex) { log.error(ex.getMessage()); ModelAndView mav = new ModelAndView(); if (ex.getRequiredType().equals(Date.class)) { mav.addObject("invalidValue", ex.getValue()); mav.addObject("exceptionText", "typeMismatch.java.util.Date"); } else { mav.addObject("exceptionText", ex.getMessage()); } return mav; }
From source file:org.openmrs.module.radiology.order.web.PortletsController.java
/** * Handle all exceptions of type TypeMismatchException which occur in this class * //w w w . j a v a 2 s. c o m * @param typeMismatchException TypeMismatchException the thrown TypeMismatchException * @return model and view with exception information * @should populate model with exception text from message properties and invalid value if date * is expected but nut passed * @should should populate model with exception text */ @ExceptionHandler(TypeMismatchException.class) public ModelAndView handleTypeMismatchException(TypeMismatchException typeMismatchException) { log.error(typeMismatchException.getMessage()); final ModelAndView mav = new ModelAndView(); if (typeMismatchException.getRequiredType().equals(Date.class)) { mav.addObject("invalidValue", typeMismatchException.getValue()); mav.addObject("exceptionText", "typeMismatch.java.util.Date"); } else { mav.addObject("exceptionText", typeMismatchException.getMessage()); } return mav; }