Java 类org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException 实例源码

项目:ss    文件:IraBankExceptionController.java   
@ExceptionHandler(value = 
        {
        Exception.class, 
        NullPointerException.class,
        NoSuchRequestHandlingMethodException.class, 
        RuntimeException.class,
        ResourceAccessException.class,
        AccessDeniedException.class,
        PropertyNotFoundException.class,
        ConstraintViolationException.class,
        NestedServletException.class}
        )

// Don't pass model object here. Seriously was creating issues here.
   public ModelAndView globalErrorHandler(HttpServletRequest request, Exception e) {
           System.out.println("comes in exception controller");
           ModelAndView mdlViewObj = new ModelAndView("/common/Exception");
           logger.error(e.getStackTrace());
           return mdlViewObj;
           //return new ModelAndView("common/Exception"); // Error java.lang.IllegalStateException: No suitable resolver for argument [0] [type=org.springframework.ui.ModelMap]
}
项目:InSpider    文件:AttributeMappingController.java   
@ModelAttribute("dataset")
public Dataset getDataset (final @PathVariable("datasetId") long datasetId, final Principal principal, final HttpServletRequest request) throws NoSuchRequestHandlingMethodException, UnauthorizedException {
    final Dataset dataset = managerDao.getDataSet (datasetId);
    if (dataset == null) {
        throw new NoSuchRequestHandlingMethodException (request);
    }

    // Check whether the current user has access to the dataset:
    final Bronhouder bronhouder = dataset.getBronhouder ();
    final Thema thema = dataset.getDatasetType ().getThema ();
    final Gebruiker gebruiker = managerDao.getGebruiker (principal.getName ());
    final Set<BronhouderThema> authorizedThemas = new HashSet<BronhouderThema> ();
    final BronhouderThema bronhouderThema = managerDao.getBronhouderThema (bronhouder, thema);

    for (final GebruikerThemaAutorisatie gta: managerDao.getGebruikerThemaAutorisatie (gebruiker)) {
        authorizedThemas.add (gta.getBronhouderThema ());
    }

    if (!gebruiker.isSuperuser () && (bronhouderThema == null || !authorizedThemas.contains (bronhouderThema))) {
        throw new UnauthorizedException (String.format ("Not authorized for dataset %d", datasetId));
    }

    return dataset;
}
项目:ABRAID-MP    文件:ErrorPageControllerTest.java   
@Test
public void getErrorPageRejectsDirectRequests() throws Exception {
    // Arrange
    ErrorPageController target = new ErrorPageController();
    Model model = mock(Model.class);
    HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getMethod()).thenReturn("GET");
    when(request.getParameterMap()).thenReturn(new HashMap<String, String[]>());
    when(request.getContextPath()).thenReturn("/publicsite");
    when(request.getRequestURI()).thenReturn("/publicsite/error");
    when(request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI)).thenReturn(null);
    HttpServletResponse response = mock(HttpServletResponse.class);
    when(response.getStatus()).thenReturn(0);

    // Act
    catchException(target).getErrorPage(model, request, response);

    // Assert
    assertThat(caughtException()).isInstanceOf(NoSuchRequestHandlingMethodException.class);
}
项目:lemon-fileservice    文件:ExceptionConfiguration.java   
/**
 * 404错误
 */
@ResponseBody
@ExceptionHandler({ NoSuchRequestHandlingMethodException.class })
public ResultResponse noSuchRequestHandlingMethodExceptionHandler(NoSuchRequestHandlingMethodException ex) {
    logger.error(ResultMessage.F4040.getMessage(), ex);
    return resultResponse.failure(ResultMessage.F4040);
}
项目:oma-riista-web    文件:WebMVCConfig.java   
@Override
public ModelAndView resolveException(HttpServletRequest request,
                                     HttpServletResponse response,
                                     Object handler,
                                     Exception ex) {
    if (ex instanceof NotFoundException) {
        LOG.error("Requested resource was not found for URI={} method={} message={}",
                request.getRequestURI(), request.getMethod(), ex.getMessage());
        return null;

    } else if (ex instanceof NoSuchRequestHandlingMethodException ||
            ex instanceof HttpRequestMethodNotSupportedException) {
        LOG.error("Handler method not found for URI={} method={}",
                request.getRequestURI(), request.getMethod());
        return null;
    }

    final ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);

    if (responseStatus != null) {
        LOG.error("Caught exception with @ResponseStatus {} with message {} for handler {}",
                ex.getClass().getSimpleName(), ex.getMessage(), getHandlerName(handler));
    } else {
        LOG.error("Handler execution resulted in exception", Throwables.getRootCause(ex));
    }

    return null;
}
项目:spring4-understanding    文件:DefaultHandlerExceptionResolverTests.java   
@Test
public void handleNoSuchRequestHandlingMethod() {
    NoSuchRequestHandlingMethodException ex = new NoSuchRequestHandlingMethodException(request);
    ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
    assertNotNull("No ModelAndView returned", mav);
    assertTrue("No Empty ModelAndView returned", mav.isEmpty());
    assertEquals("Invalid status code", 404, response.getStatus());
}
项目:simbest-cores    文件:ExceptionControllerAdvice.java   
/**
   * 页面找不到404
   * @param request
   * @param e
   * @return
   */
  @ExceptionHandler({NoSuchRequestHandlingMethodException.class})
  @ResponseStatus(HttpStatus.NOT_FOUND)
  @ResponseBody
  public JsonResponse noSuchRequestHandlingMethod(HttpServletRequest request, Exception e) {
log.error(request.getRequestURI());
Exceptions.printException(e);
    JsonResponse response = new JsonResponse();             
response.setMessage("请求的资源不存在!");
response.setResponseid(0);
return response;
  }
项目:AgileAlligators    文件:FacilityAdvice.java   
@Override
protected ResponseEntity<Object> handleNoSuchRequestHandlingMethod( NoSuchRequestHandlingMethodException ex, HttpHeaders headers, HttpStatus status, WebRequest request )
{
    headers.add( "Content-Type", MediaType.APPLICATION_JSON_VALUE );

    return new ResponseEntity<>( MessageUtils.jsonMessage(
        Integer.toString( status.value() ), ex.getMessage() ), status );
}
项目:podcastpedia-web    文件:EpisodeController.java   
@ExceptionHandler({ NoSuchRequestHandlingMethodException.class,
        ConversionNotSupportedException.class })
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public String handleResourceNotFound(ModelMap model) {
    model.put("advancedSearchData", new SearchData());
    return "resourceNotFound";
}
项目:class-guard    文件:DefaultHandlerExceptionResolverTests.java   
@Test
public void handleNoSuchRequestHandlingMethod() {
    NoSuchRequestHandlingMethodException ex = new NoSuchRequestHandlingMethodException(request);
    ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
    assertNotNull("No ModelAndView returned", mav);
    assertTrue("No Empty ModelAndView returned", mav.isEmpty());
    assertEquals("Invalid status code", 404, response.getStatus());
}
项目:chuidiang-ejemplos    文件:GreetingController.java   
@RequestMapping(method = RequestMethod.DELETE, path = "/greeting/{id}")
public void delete(@PathVariable Integer id)
      throws NoSuchRequestHandlingMethodException {
   try {
      data.removeGreeting(id);
   } catch (IndexOutOfBoundsException e) {
      throw new NoSuchRequestHandlingMethodException("greeting",
            GreetingController.class);
   }
}
项目:chuidiang-ejemplos    文件:GreetingController.java   
@RequestMapping(method = RequestMethod.PUT, path = "/greeting/{id}")
public Greeting add(@PathVariable Integer id,
      @RequestBody Greeting greeting)
            throws NoSuchRequestHandlingMethodException {
   try {
      return data.updateGreeting(id, greeting);
   } catch (IndexOutOfBoundsException e) {
      throw new NoSuchRequestHandlingMethodException("greeting",
            GreetingController.class);
   }
}
项目:restjplat    文件:DefaultRestErrorResolver.java   
/**
 * 将spring中的http状态和异常互相对应 参考 spring的defaultExceptionHandler实现类似
 * 
 * @return
 */
private final Map<String, String> createDefaultExceptionMappingDefinitions() {

    Map<String, String> m = new LinkedHashMap<String, String>();

    // 400
    applyDef(m, HttpMessageNotReadableException.class,
            HttpStatus.BAD_REQUEST);
    applyDef(m, MissingServletRequestParameterException.class,
            HttpStatus.BAD_REQUEST);
    applyDef(m, TypeMismatchException.class, HttpStatus.BAD_REQUEST);
    applyDef(m, "javax.validation.ValidationException",
            HttpStatus.BAD_REQUEST);

    // 404
    applyDef(m, NoSuchRequestHandlingMethodException.class,
            HttpStatus.NOT_FOUND);
    applyDef(m, "org.hibernate.ObjectNotFoundException",
            HttpStatus.NOT_FOUND);

    // 405
    applyDef(m, HttpRequestMethodNotSupportedException.class,
            HttpStatus.METHOD_NOT_ALLOWED);

    // 406
    applyDef(m, HttpMediaTypeNotAcceptableException.class,
            HttpStatus.NOT_ACCEPTABLE);

    // 409
    applyDef(m, "org.springframework.dao.DataIntegrityViolationException",
            HttpStatus.CONFLICT);

    // 415
    applyDef(m, HttpMediaTypeNotSupportedException.class,
            HttpStatus.UNSUPPORTED_MEDIA_TYPE);
    return m;
}
项目:sinavi-jfw    文件:AbstractRestExceptionHandler.java   
/**
 * {@link NoSuchRequestHandlingMethodException}をハンドリングします。
 * @param e {@link NoSuchRequestHandlingMethodException}
 * @return {@link ErrorMessage}
 *         HTTPステータス 404 でレスポンスを返却します。
 */
@ExceptionHandler(NoSuchRequestHandlingMethodException.class)
@ResponseBody
@ResponseStatus(value = HttpStatus.NOT_FOUND)
@Override
public ErrorMessage handle(NoSuchRequestHandlingMethodException e) {
    if (L.isDebugEnabled()) {
        L.debug(R.getString("D-SPRINGMVC-REST-HANDLER#0001"), e);
    }
    ErrorMessage error = createClientErrorMessage(HttpStatus.NOT_FOUND);
    warn(error, e);
    return error;
}
项目:sinavi-jfw    文件:RestDefaultExceptionHandlerTest.java   
@Test
public void NoSuchRequestHandlingMethodExceptionをハンドリングできる() {
    NoSuchRequestHandlingMethodException ex = new NoSuchRequestHandlingMethodException("", "", null);
    ErrorMessage message = this.exceptionHandlerSupport.handle(ex);
    assertThat(message, notNullValue());
    assertThat(message.getStatus(), is(404));
    assertThat(message.getMessage(), is("リソースが見つかりません。"));
}
项目:ABRAID-MP    文件:ErrorPageController.java   
/**
 * Show the error page.
 * @param model The page template model.
 * @param request The HTTP request (this is a second request caused by the internal redirection of error pages).
 * @param response The HTTP response.
 * @return The page template name.
 * @throws NoSuchRequestHandlingMethodException 404 if the hit on this RequestMapping is caused by somebody viewing
 *                                              "/error" instead of by the internal redirect.
 */
@RequestMapping(value = "/error")
public String getErrorPage(Model model, HttpServletRequest request, HttpServletResponse response)
        throws NoSuchRequestHandlingMethodException {
    int status = response.getStatus();
    preventExternalRequests(request, status);
    String originalUri = getOriginalServletPath(request);

    LOGGER.warn(String.format("Showing error page due to %s accessing '%s'.", status, originalUri));

    model.addAttribute("status", status);
    model.addAttribute("uri", originalUri);
    return "error";
}
项目:ABRAID-MP    文件:ErrorPageController.java   
private void preventExternalRequests(HttpServletRequest request, int status)
        throws NoSuchRequestHandlingMethodException {
    if (status == 0) {
        // This request mapping is for internal error access (via web.xml <errorpage>) only. If we get a normal hit
        // on it, throw a 404 (which will end up back here via DefaultHandlerExceptionResolver).
        throw new NoSuchRequestHandlingMethodException(request);
    }
}
项目:spring-rest-exception-handler    文件:RestHandlerExceptionResolverBuilder.java   
private Map<Class, RestExceptionHandler> getDefaultHandlers() {

        Map<Class, RestExceptionHandler> map = new HashMap<>();

        map.put( NoSuchRequestHandlingMethodException.class, new NoSuchRequestHandlingMethodExceptionHandler() );
        map.put( HttpRequestMethodNotSupportedException.class, new HttpRequestMethodNotSupportedExceptionHandler() );
        map.put( HttpMediaTypeNotSupportedException.class, new HttpMediaTypeNotSupportedExceptionHandler() );
        map.put( MethodArgumentNotValidException.class, new MethodArgumentNotValidExceptionHandler() );

        if (ClassUtils.isPresent("javax.validation.ConstraintViolationException", getClass().getClassLoader())) {
            map.put( ConstraintViolationException.class, new ConstraintViolationExceptionHandler() );
        }

        addHandlerTo( map, HttpMediaTypeNotAcceptableException.class, NOT_ACCEPTABLE );
        addHandlerTo( map, MissingServletRequestParameterException.class, BAD_REQUEST );
        addHandlerTo( map, ServletRequestBindingException.class, BAD_REQUEST );
        addHandlerTo( map, ConversionNotSupportedException.class, INTERNAL_SERVER_ERROR );
        addHandlerTo( map, TypeMismatchException.class, BAD_REQUEST );
        addHandlerTo( map, HttpMessageNotReadableException.class, UNPROCESSABLE_ENTITY );
        addHandlerTo( map, HttpMessageNotWritableException.class, INTERNAL_SERVER_ERROR );
        addHandlerTo( map, MissingServletRequestPartException.class, BAD_REQUEST );
        addHandlerTo(map, Exception.class, INTERNAL_SERVER_ERROR);

        // this class didn't exist before Spring 4.0
        try {
            Class clazz = Class.forName("org.springframework.web.servlet.NoHandlerFoundException");
            addHandlerTo(map, clazz, NOT_FOUND);
        } catch (ClassNotFoundException ex) {
            // ignore
        }
        return map;
    }
项目:RID-Server    文件:RIDRequestHandler.java   
@RequestMapping(method = RequestMethod.POST)
public String handleRequest(HttpServletRequest request, HttpServletResponse response, Model model) throws XProcException, IOException, URISyntaxException, TransformerException, NoSuchRequestHandlingMethodException {
    try {

        // check the white list to see if we want to talk to the counter-party
        logger.info("If we got this far, the Spring Security whitelist checking has already passed OK...");

        SecurityContext ssc = SecurityContextHolder.getContext();
        String ridPeerName = ssc.getAuthentication().getName().toString();

        if (ridPeerName != null) {
            logger.info("RID Peer Name is: " + ridPeerName);
            if (!whiteList.contains(ridPeerName)) {
                logger.info("RID Peer name not found in whitelist.");
                logger.info("Edit RIDSystem-servlet.xml if and as appropriate, in order to authorize this peer.");
                throw new NoSuchRequestHandlingMethodException(request); // results in a 404 Not Found.
            }
            logger.info("Local whitelist Checking completed.");
            logger.info("Incoming WatchList.   "+request.getInputStream().toString());
        }

        PipelineInputCache pi = new PipelineInputCache();

        // supply HTTP body as the source for the resource Create pipeline
        pi.setInputPort("source", request.getInputStream());            

        PipelineOutput output = m_requestHandler.executeOn(pi);

        model.addAttribute("pipelineOutput", output);
        return "pipelineOutput";
    } finally {
        ; //TODO add finally handler
    }
}
项目:spring4-understanding    文件:DefaultHandlerExceptionResolver.java   
@Override
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
        Object handler, Exception ex) {

    try {
        if (ex instanceof NoSuchRequestHandlingMethodException) {
            return handleNoSuchRequestHandlingMethod((NoSuchRequestHandlingMethodException) ex, request, response,
                    handler);
        }
        else if (ex instanceof HttpRequestMethodNotSupportedException) {
            return handleHttpRequestMethodNotSupported((HttpRequestMethodNotSupportedException) ex, request,
                    response, handler);
        }
        else if (ex instanceof HttpMediaTypeNotSupportedException) {
            return handleHttpMediaTypeNotSupported((HttpMediaTypeNotSupportedException) ex, request, response,
                    handler);
        }
        else if (ex instanceof HttpMediaTypeNotAcceptableException) {
            return handleHttpMediaTypeNotAcceptable((HttpMediaTypeNotAcceptableException) ex, request, response,
                    handler);
        }
        else if (ex instanceof MissingPathVariableException) {
            return handleMissingPathVariable((MissingPathVariableException) ex, request,
                    response, handler);
        }
        else if (ex instanceof MissingServletRequestParameterException) {
            return handleMissingServletRequestParameter((MissingServletRequestParameterException) ex, request,
                    response, handler);
        }
        else if (ex instanceof ServletRequestBindingException) {
            return handleServletRequestBindingException((ServletRequestBindingException) ex, request, response,
                    handler);
        }
        else if (ex instanceof ConversionNotSupportedException) {
            return handleConversionNotSupported((ConversionNotSupportedException) ex, request, response, handler);
        }
        else if (ex instanceof TypeMismatchException) {
            return handleTypeMismatch((TypeMismatchException) ex, request, response, handler);
        }
        else if (ex instanceof HttpMessageNotReadableException) {
            return handleHttpMessageNotReadable((HttpMessageNotReadableException) ex, request, response, handler);
        }
        else if (ex instanceof HttpMessageNotWritableException) {
            return handleHttpMessageNotWritable((HttpMessageNotWritableException) ex, request, response, handler);
        }
        else if (ex instanceof MethodArgumentNotValidException) {
            return handleMethodArgumentNotValidException((MethodArgumentNotValidException) ex, request, response,
                    handler);
        }
        else if (ex instanceof MissingServletRequestPartException) {
            return handleMissingServletRequestPartException((MissingServletRequestPartException) ex, request,
                    response, handler);
        }
        else if (ex instanceof BindException) {
            return handleBindException((BindException) ex, request, response, handler);
        }
        else if (ex instanceof NoHandlerFoundException) {
            return handleNoHandlerFoundException((NoHandlerFoundException) ex, request, response, handler);
        }
    }
    catch (Exception handlerException) {
        if (logger.isWarnEnabled()) {
            logger.warn("Handling of [" + ex.getClass().getName() + "] resulted in Exception", handlerException);
        }
    }
    return null;
}
项目:spring4-understanding    文件:ResponseEntityExceptionHandlerTests.java   
@Test
public void noSuchRequestHandlingMethod() {
    Exception ex = new NoSuchRequestHandlingMethodException("GET", TestController.class);
    testException(ex);
}
项目:easy-mybatis    文件:RestExceptionHandler.java   
@ExceptionHandler({NoSuchRequestHandlingMethodException.class,
        HttpRequestMethodNotSupportedException.class,
        HttpMediaTypeNotSupportedException.class,
        HttpMediaTypeNotAcceptableException.class,
        MissingServletRequestParameterException.class,
        ServletRequestBindingException.class,
        ConversionNotSupportedException.class,
        TypeMismatchException.class,
        HttpMessageNotReadableException.class,
        HttpMessageNotWritableException.class,
        MethodArgumentNotValidException.class,
        MissingServletRequestPartException.class,
        BindException.class,
        NoHandlerFoundException.class})
public final ResponseEntity<Object> handleException(Exception ex, HttpServletRequest request) {
    HttpHeaders headers = new HttpHeaders();
    HttpStatus status;
    if(ex instanceof NoSuchRequestHandlingMethodException) {
        status = HttpStatus.NOT_FOUND;
        return handleNoSuchRequestHandlingMethod((NoSuchRequestHandlingMethodException)ex, headers, status, request);
    } else if(ex instanceof HttpRequestMethodNotSupportedException) {
        status = HttpStatus.METHOD_NOT_ALLOWED;
        return handleHttpRequestMethodNotSupported((HttpRequestMethodNotSupportedException)ex, headers, status, request);
    } else if(ex instanceof HttpMediaTypeNotSupportedException) {
        status = HttpStatus.UNSUPPORTED_MEDIA_TYPE;
        return handleHttpMediaTypeNotSupported((HttpMediaTypeNotSupportedException)ex, headers, status, request);
    } else if(ex instanceof HttpMediaTypeNotAcceptableException) {
        status = HttpStatus.NOT_ACCEPTABLE;
        return handleHttpMediaTypeNotAcceptable((HttpMediaTypeNotAcceptableException)ex, headers, status, request);
    } else if(ex instanceof MissingServletRequestParameterException) {
        status = HttpStatus.BAD_REQUEST;
        return handleMissingServletRequestParameter((MissingServletRequestParameterException)ex, headers, status, request);
    } else if(ex instanceof ServletRequestBindingException) {
        status = HttpStatus.BAD_REQUEST;
        return handleServletRequestBindingException((ServletRequestBindingException)ex, headers, status, request);
    } else if(ex instanceof ConversionNotSupportedException) {
        status = HttpStatus.INTERNAL_SERVER_ERROR;
        return handleConversionNotSupported((ConversionNotSupportedException)ex, headers, status, request);
    } else if(ex instanceof TypeMismatchException) {
        status = HttpStatus.BAD_REQUEST;
        return handleTypeMismatch((TypeMismatchException)ex, headers, status, request);
    } else if(ex instanceof HttpMessageNotReadableException) {
        status = HttpStatus.BAD_REQUEST;
        return handleHttpMessageNotReadable((HttpMessageNotReadableException)ex, headers, status, request);
    } else if(ex instanceof HttpMessageNotWritableException) {
        status = HttpStatus.INTERNAL_SERVER_ERROR;
        return handleHttpMessageNotWritable((HttpMessageNotWritableException)ex, headers, status, request);
    } else if(ex instanceof MethodArgumentNotValidException) {
        status = HttpStatus.BAD_REQUEST;
        return handleMethodArgumentNotValid((MethodArgumentNotValidException)ex, headers, status, request);
    } else if(ex instanceof MissingServletRequestPartException) {
        status = HttpStatus.BAD_REQUEST;
        return handleMissingServletRequestPart((MissingServletRequestPartException)ex, headers, status, request);
    } else if(ex instanceof BindException) {
        status = HttpStatus.BAD_REQUEST;
        return handleBindingResult(((BindException) ex).getBindingResult(), (BindException)ex, null, headers, status, request);
    } else if(ex instanceof NoHandlerFoundException) {
        status = HttpStatus.NOT_FOUND;
        return handleNoHandlerFoundException((NoHandlerFoundException)ex, headers, status, request);
    } else {
        logger.warn("Unknown exception type: " + ex.getClass().getName());
        status = HttpStatus.INTERNAL_SERVER_ERROR;
        return handleExceptionInternal(ex, (Object)null, headers, status, request);
    }
}
项目:easy-mybatis    文件:RestExceptionHandler.java   
protected ResponseEntity<Object> handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex, HttpHeaders headers, HttpStatus status, HttpServletRequest request) {
    pageNotFoundLogger.warn(ex.getMessage());
    return handleExceptionInternal(ex, (Object) null, headers, status, request);
}
项目:easy-mybatis    文件:RestExceptionHandler.java   
@ExceptionHandler({NoSuchRequestHandlingMethodException.class,
        HttpRequestMethodNotSupportedException.class,
        HttpMediaTypeNotSupportedException.class,
        HttpMediaTypeNotAcceptableException.class,
        MissingServletRequestParameterException.class,
        ServletRequestBindingException.class,
        ConversionNotSupportedException.class,
        TypeMismatchException.class,
        HttpMessageNotReadableException.class,
        HttpMessageNotWritableException.class,
        MethodArgumentNotValidException.class,
        MissingServletRequestPartException.class,
        BindException.class,
        NoHandlerFoundException.class})
public final ResponseEntity<Object> handleException(Exception ex, HttpServletRequest request) {
    HttpHeaders headers = new HttpHeaders();
    HttpStatus status;
    if(ex instanceof NoSuchRequestHandlingMethodException) {
        status = HttpStatus.NOT_FOUND;
        return handleNoSuchRequestHandlingMethod((NoSuchRequestHandlingMethodException)ex, headers, status, request);
    } else if(ex instanceof HttpRequestMethodNotSupportedException) {
        status = HttpStatus.METHOD_NOT_ALLOWED;
        return handleHttpRequestMethodNotSupported((HttpRequestMethodNotSupportedException)ex, headers, status, request);
    } else if(ex instanceof HttpMediaTypeNotSupportedException) {
        status = HttpStatus.UNSUPPORTED_MEDIA_TYPE;
        return handleHttpMediaTypeNotSupported((HttpMediaTypeNotSupportedException)ex, headers, status, request);
    } else if(ex instanceof HttpMediaTypeNotAcceptableException) {
        status = HttpStatus.NOT_ACCEPTABLE;
        return handleHttpMediaTypeNotAcceptable((HttpMediaTypeNotAcceptableException)ex, headers, status, request);
    } else if(ex instanceof MissingServletRequestParameterException) {
        status = HttpStatus.BAD_REQUEST;
        return handleMissingServletRequestParameter((MissingServletRequestParameterException)ex, headers, status, request);
    } else if(ex instanceof ServletRequestBindingException) {
        status = HttpStatus.BAD_REQUEST;
        return handleServletRequestBindingException((ServletRequestBindingException)ex, headers, status, request);
    } else if(ex instanceof ConversionNotSupportedException) {
        status = HttpStatus.INTERNAL_SERVER_ERROR;
        return handleConversionNotSupported((ConversionNotSupportedException)ex, headers, status, request);
    } else if(ex instanceof TypeMismatchException) {
        status = HttpStatus.BAD_REQUEST;
        return handleTypeMismatch((TypeMismatchException)ex, headers, status, request);
    } else if(ex instanceof HttpMessageNotReadableException) {
        status = HttpStatus.BAD_REQUEST;
        return handleHttpMessageNotReadable((HttpMessageNotReadableException)ex, headers, status, request);
    } else if(ex instanceof HttpMessageNotWritableException) {
        status = HttpStatus.INTERNAL_SERVER_ERROR;
        return handleHttpMessageNotWritable((HttpMessageNotWritableException)ex, headers, status, request);
    } else if(ex instanceof MethodArgumentNotValidException) {
        status = HttpStatus.BAD_REQUEST;
        return handleMethodArgumentNotValid((MethodArgumentNotValidException)ex, headers, status, request);
    } else if(ex instanceof MissingServletRequestPartException) {
        status = HttpStatus.BAD_REQUEST;
        return handleMissingServletRequestPart((MissingServletRequestPartException)ex, headers, status, request);
    } else if(ex instanceof BindException) {
        status = HttpStatus.BAD_REQUEST;
        return handleBindingResult(((BindException) ex).getBindingResult(), (BindException)ex, null, headers, status, request);
    } else if(ex instanceof NoHandlerFoundException) {
        status = HttpStatus.NOT_FOUND;
        return handleNoHandlerFoundException((NoHandlerFoundException)ex, headers, status, request);
    } else {
        logger.warn("Unknown exception type: " + ex.getClass().getName());
        status = HttpStatus.INTERNAL_SERVER_ERROR;
        return handleExceptionInternal(ex, (Object)null, headers, status, request);
    }
}
项目:easy-mybatis    文件:RestExceptionHandler.java   
protected ResponseEntity<Object> handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex, HttpHeaders headers, HttpStatus status, HttpServletRequest request) {
    pageNotFoundLogger.warn(ex.getMessage());
    return handleExceptionInternal(ex, (Object) null, headers, status, request);
}
项目:boot-camper    文件:BaseResource.java   
@ExceptionHandler({NoSuchRequestHandlingMethodException.class})
@ResponseStatus(NOT_ACCEPTABLE)
public void handleMediaTypeNotAcceptable()
{
}
项目:eHMP    文件:AjaxHandlerExceptionResolver.java   
@Override
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex, HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
    super.handleNoSuchRequestHandlingMethod(ex, request, response, handler);
    return contentNegotiatingModelAndView(createErrorResponse(request, HttpServletResponse.SC_NOT_FOUND, ex));
}
项目:podcastpedia-web    文件:PodcastIdentifierController.java   
@ExceptionHandler({ NoSuchRequestHandlingMethodException.class,
        ConversionNotSupportedException.class })
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public String handleResourceNotFound() {
    return "resourceNotFound";
}
项目:podcastpedia-web    文件:PodcastController.java   
@ExceptionHandler({NoSuchRequestHandlingMethodException.class, ConversionNotSupportedException.class})
@ResponseStatus(value = HttpStatus.NOT_FOUND)         
public String handleResourceNotFound(){
 return "resourceNotFound";
}
项目:class-guard    文件:DefaultHandlerExceptionResolver.java   
@Override
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
        Object handler, Exception ex) {

    try {
        if (ex instanceof NoSuchRequestHandlingMethodException) {
            return handleNoSuchRequestHandlingMethod((NoSuchRequestHandlingMethodException) ex, request, response,
                    handler);
        }
        else if (ex instanceof HttpRequestMethodNotSupportedException) {
            return handleHttpRequestMethodNotSupported((HttpRequestMethodNotSupportedException) ex, request,
                    response, handler);
        }
        else if (ex instanceof HttpMediaTypeNotSupportedException) {
            return handleHttpMediaTypeNotSupported((HttpMediaTypeNotSupportedException) ex, request, response,
                    handler);
        }
        else if (ex instanceof HttpMediaTypeNotAcceptableException) {
            return handleHttpMediaTypeNotAcceptable((HttpMediaTypeNotAcceptableException) ex, request, response,
                    handler);
        }
        else if (ex instanceof MissingServletRequestParameterException) {
            return handleMissingServletRequestParameter((MissingServletRequestParameterException) ex, request,
                    response, handler);
        }
        else if (ex instanceof ServletRequestBindingException) {
            return handleServletRequestBindingException((ServletRequestBindingException) ex, request, response,
                    handler);
        }
        else if (ex instanceof ConversionNotSupportedException) {
            return handleConversionNotSupported((ConversionNotSupportedException) ex, request, response, handler);
        }
        else if (ex instanceof TypeMismatchException) {
            return handleTypeMismatch((TypeMismatchException) ex, request, response, handler);
        }
        else if (ex instanceof HttpMessageNotReadableException) {
            return handleHttpMessageNotReadable((HttpMessageNotReadableException) ex, request, response, handler);
        }
        else if (ex instanceof HttpMessageNotWritableException) {
            return handleHttpMessageNotWritable((HttpMessageNotWritableException) ex, request, response, handler);
        }
        else if (ex instanceof MethodArgumentNotValidException) {
            return handleMethodArgumentNotValidException((MethodArgumentNotValidException) ex, request, response, handler);
        }
        else if (ex instanceof MissingServletRequestPartException) {
            return handleMissingServletRequestPartException((MissingServletRequestPartException) ex, request, response, handler);
        }
        else if (ex instanceof BindException) {
            return handleBindException((BindException) ex, request, response, handler);
        }
    }
    catch (Exception handlerException) {
        logger.warn("Handling of [" + ex.getClass().getName() + "] resulted in Exception", handlerException);
    }
    return null;
}
项目:class-guard    文件:ResponseEntityExceptionHandlerTests.java   
@Test
public void noSuchRequestHandlingMethod() {
    Exception ex = new NoSuchRequestHandlingMethodException("GET", TestController.class);
    testException(ex);
}
项目:spring-rest-exception-handler    文件:NoSuchRequestHandlingMethodExceptionHandler.java   
@Override
public ResponseEntity<ErrorMessage> handleException(NoSuchRequestHandlingMethodException ex, HttpServletRequest req) {

    LOG.warn(ex.getMessage());
    return super.handleException(ex, req);
}
项目:spring4-understanding    文件:DefaultHandlerExceptionResolver.java   
/**
 * Handle the case where no request handler method was found.
 * <p>The default implementation logs a warning, sends an HTTP 404 error, and returns
 * an empty {@code ModelAndView}. Alternatively, a fallback view could be chosen,
 * or the NoSuchRequestHandlingMethodException could be rethrown as-is.
 * @param ex the NoSuchRequestHandlingMethodException to be handled
 * @param request current HTTP request
 * @param response current HTTP response
 * @param handler the executed handler, or {@code null} if none chosen
 * at the time of the exception (for example, if multipart resolution failed)
 * @return an empty ModelAndView indicating the exception was handled
 * @throws IOException potentially thrown from response.sendError()
 */
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex,
        HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {

    pageNotFoundLogger.warn(ex.getMessage());
    response.sendError(HttpServletResponse.SC_NOT_FOUND);
    return new ModelAndView();
}
项目:spring4-understanding    文件:ResponseEntityExceptionHandler.java   
/**
 * Customize the response for NoSuchRequestHandlingMethodException.
 * <p>This method logs a warning and delegates to {@link #handleExceptionInternal}.
 * @param ex the exception
 * @param headers the headers to be written to the response
 * @param status the selected response status
 * @param request the current request
 * @return a {@code ResponseEntity} instance
 */
protected ResponseEntity<Object> handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex,
        HttpHeaders headers, HttpStatus status, WebRequest request) {

    pageNotFoundLogger.warn(ex.getMessage());

    return handleExceptionInternal(ex, null, headers, status, request);
}
项目:class-guard    文件:DefaultHandlerExceptionResolver.java   
/**
 * Handle the case where no request handler method was found.
 * <p>The default implementation logs a warning, sends an HTTP 404 error, and returns
 * an empty {@code ModelAndView}. Alternatively, a fallback view could be chosen,
 * or the NoSuchRequestHandlingMethodException could be rethrown as-is.
 * @param ex the NoSuchRequestHandlingMethodException to be handled
 * @param request current HTTP request
 * @param response current HTTP response
 * @param handler the executed handler, or {@code null} if none chosen
 * at the time of the exception (for example, if multipart resolution failed)
 * @return an empty ModelAndView indicating the exception was handled
 * @throws IOException potentially thrown from response.sendError()
 */
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex,
        HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {

    pageNotFoundLogger.warn(ex.getMessage());
    response.sendError(HttpServletResponse.SC_NOT_FOUND);
    return new ModelAndView();
}
项目:class-guard    文件:ResponseEntityExceptionHandler.java   
/**
 * Customize the response for NoSuchRequestHandlingMethodException.
 * This method logs a warning and delegates to
 * {@link #handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatus, WebRequest)}.
 * @param ex the exception
 * @param headers the headers to be written to the response
 * @param status the selected response status
 * @param request the current request
 * @return a {@code ResponseEntity} instance
 */
protected ResponseEntity<Object> handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex,
        HttpHeaders headers, HttpStatus status, WebRequest request) {

    pageNotFoundLogger.warn(ex.getMessage());

    return handleExceptionInternal(ex, null, headers, status, request);
}
项目:sinavi-jfw    文件:RestExceptionHandler.java   
/**
 * {@link NoSuchRequestHandlingMethodException}をハンドリングします。
 * @param e {@link NoSuchRequestHandlingMethodException}
 * @return 任意の型
 */
T handle(NoSuchRequestHandlingMethodException e);