List of usage examples for org.springframework.web.bind ServletRequestBindingException getMessage
@Override
@Nullable
public String getMessage()
From source file:gov.nyc.doitt.gis.geoclient.service.web.RestController.java
@ExceptionHandler(value = { MissingAnyOfOptionalServletRequestParametersException.class,
MissingServletRequestParameterException.class })
public @ResponseBody ResponseEntity<BadRequest> handleMissingRequestParameter(
ServletRequestBindingException exception, HttpServletRequest req) {
BadRequest badRequest = new BadRequest();
badRequest.setHttpStatus(HttpStatus.BAD_REQUEST.toString());
badRequest.setMessage(exception.getMessage());
badRequest.setRequestUri(String.format("%s?%s", req.getRequestURI(), req.getQueryString()));
return new ResponseEntity<BadRequest>(badRequest, HttpStatus.BAD_REQUEST);
}
From source file:net.unicon.cas.mfa.web.MultiFactorServiceValidateController.java
/** * Get the authentication method parameter. * @param request request object/*from ww w .ja v a 2 s. com*/ * @return the value of the authentication method parameter, or null if it can't be obtained */ private String getAuthenticationMethodFromRequest(final HttpServletRequest request) { try { return ServletRequestUtils.getStringParameter(request, MultiFactorAuthenticationSupportingWebApplicationService.CONST_PARAM_AUTHN_METHOD); } catch (final ServletRequestBindingException e) { logger.error(e.getMessage(), e); } return null; }
From source file:org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.java
/** * Handle the case when an unrecoverable binding exception occurs - e.g. required header, required cookie. * <p>The default implementation sends an HTTP 400 error, and returns an empty {@code ModelAndView}. * Alternatively, a fallback view could be chosen, or the exception could be rethrown as-is. * @param ex the exception to be handled * @param request current HTTP request/*from ww w.j a v a2s.co m*/ * @param response current HTTP response * @param handler the executed handler * @return an empty ModelAndView indicating the exception was handled * @throws IOException potentially thrown from response.sendError() */ protected ModelAndView handleServletRequestBindingException(ServletRequestBindingException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException { response.sendError(HttpServletResponse.SC_BAD_REQUEST, ex.getMessage()); return new ModelAndView(); }