Example usage for org.springframework.web.bind MissingPathVariableException getMessage

List of usage examples for org.springframework.web.bind MissingPathVariableException getMessage

Introduction

In this page you can find the example usage for org.springframework.web.bind MissingPathVariableException getMessage.

Prototype

@Override
    public String getMessage() 

Source Link

Usage

From source file:org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.java

/**
 * Handle the case when a declared path variable does not match any extracted URI variable.
 * <p>The default implementation sends an HTTP 500 error, and returns an empty {@code ModelAndView}.
 * Alternatively, a fallback view could be chosen, or the MissingPathVariableException
 * could be rethrown as-is.//from  ww w  .j av a  2 s . co  m
 * @param ex the MissingPathVariableException to be handled
 * @param request current HTTP request
 * @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()
 * @since 4.2
 */
protected ModelAndView handleMissingPathVariable(MissingPathVariableException ex, HttpServletRequest request,
        HttpServletResponse response, @Nullable Object handler) throws IOException {

    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage());
    return new ModelAndView();
}