Example usage for org.springframework.web.multipart.support MissingServletRequestPartException getMessage

List of usage examples for org.springframework.web.multipart.support MissingServletRequestPartException getMessage

Introduction

In this page you can find the example usage for org.springframework.web.multipart.support MissingServletRequestPartException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

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

/**
 * Handle the case where an {@linkplain RequestPart @RequestPart}, a {@link MultipartFile},
 * or a {@code javax.servlet.http.Part} argument is required but is missing.
 * An HTTP 400 error is sent back to the client.
 * @param request current HTTP request/*w w w . j  av a  2s  . c o  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 handleMissingServletRequestPartException(MissingServletRequestPartException ex,
        HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {

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