List of usage examples for org.springframework.web.servlet NoHandlerFoundException NoHandlerFoundException
public NoHandlerFoundException(String httpMethod, String requestURL, HttpHeaders headers)
From source file:com.monarchapis.driver.spring.rest.ApiErrorResponseEntityExceptionHandlerTest.java
@Test public void testNoHandlerFoundException() { performTest(// new NoHandlerFoundException("test", "test", null), // 404, // "notFound"); }
From source file:org.springframework.web.servlet.DispatcherServlet.java
/** * No handler found -> set appropriate HTTP response status. * @param request current HTTP request/*from w ww .j a v a 2 s .c om*/ * @param response current HTTP response * @throws Exception if preparing the response failed */ protected void noHandlerFound(HttpServletRequest request, HttpServletResponse response) throws Exception { if (pageNotFoundLogger.isWarnEnabled()) { pageNotFoundLogger.warn("No mapping found for HTTP request with URI [" + getRequestUri(request) + "] in DispatcherServlet with name '" + getServletName() + "'"); } if (this.throwExceptionIfNoHandlerFound) { throw new NoHandlerFoundException(request.getMethod(), getRequestUri(request), new ServletServerHttpRequest(request).getHeaders()); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } }
From source file:org.springframework.web.servlet.DispatcherServletMod.java
/** * No handler found -> set appropriate HTTP response status. * //from w ww.j a v a2 s .com * @param request * current HTTP request * @param response * current HTTP response * @throws Exception * if preparing the response failed */ protected void noHandlerFound(HttpServletRequest request, HttpServletResponse response) throws Exception { if (pageNotFoundLogger.isWarnEnabled()) { String requestUri = urlPathHelper.getRequestUri(request); pageNotFoundLogger.warn("No mapping found for HTTP request with URI [" + requestUri + "] in DispatcherServlet with name '" + getServletName() + "'"); } if (throwExceptionIfNoHandlerFound) { ServletServerHttpRequest req = new ServletServerHttpRequest(request); throw new NoHandlerFoundException(req.getMethod().name(), req.getServletRequest().getRequestURI(), req.getHeaders()); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } }