Package org.springframework.web.bind.annotation

Examples of org.springframework.web.bind.annotation.ResponseStatus


    @SuppressWarnings("unchecked")
    public ModelAndView getModelAndView(Method handlerMethod, Class handlerType, Object returnValue,
        ExtendedModelMap implicitModel, ServletWebRequest webRequest) throws Exception {

      ResponseStatus responseStatusAnn = AnnotationUtils.findAnnotation(handlerMethod, ResponseStatus.class);
      if (responseStatusAnn != null) {
        HttpStatus responseStatus = responseStatusAnn.value();
        // to be picked up by the RedirectView
        webRequest.getRequest().setAttribute(View.RESPONSE_STATUS_ATTRIBUTE, responseStatus);
        webRequest.getResponse().setStatus(responseStatus.value());
        responseArgumentUsed = true;
      }
View Full Code Here


  @SuppressWarnings("unchecked")
  private ModelAndView getModelAndView(Method handlerMethod, Object returnValue, ServletWebRequest webRequest)
      throws Exception {

    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(handlerMethod, ResponseStatus.class);
    if (responseStatus != null) {
      HttpServletResponse response = webRequest.getResponse();
      response.setStatus(responseStatus.value().value());
    }
    if (returnValue instanceof ModelAndView) {
      return (ModelAndView) returnValue;
    }
    else if (returnValue instanceof Model) {
View Full Code Here

  @Override
  protected ModelAndView doResolveException(HttpServletRequest request,
      HttpServletResponse response,
      Object handler,
      Exception ex) {
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
      try {
        return resolveResponseStatus(responseStatus, request, response, handler, ex);
      }
      catch (Exception resolveEx) {
View Full Code Here

        LOG.log(status == HttpStatus.INTERNAL_SERVER_ERROR ? Level.WARNING : Level.FINE, e.getMessage(), e);
        return IO.error(new JSONObj(), e );
    }

    HttpStatus status(Exception e) {
        ResponseStatus status = e.getClass().getAnnotation(ResponseStatus.class);
        return status != null ? status.value() : HttpStatus.INTERNAL_SERVER_ERROR;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public ModelAndView getModelAndView(Method handlerMethod, Class handlerType, Object returnValue,
        ExtendedModelMap implicitModel, ServletWebRequest webRequest) throws Exception {

      ResponseStatus responseStatusAnn = AnnotationUtils.findAnnotation(handlerMethod, ResponseStatus.class);
      if (responseStatusAnn != null) {
        HttpStatus responseStatus = responseStatusAnn.value();
        String reason = responseStatusAnn.reason();
        if (!StringUtils.hasText(reason)) {
          webRequest.getResponse().setStatus(responseStatus.value());
        }
        else {
          webRequest.getResponse().sendError(responseStatus.value(), reason);
View Full Code Here

  @SuppressWarnings("unchecked")
  private ModelAndView getModelAndView(Method handlerMethod, Object returnValue, ServletWebRequest webRequest)
      throws Exception {

    ResponseStatus responseStatusAnn = AnnotationUtils.findAnnotation(handlerMethod, ResponseStatus.class);
    if (responseStatusAnn != null) {
      HttpStatus responseStatus = responseStatusAnn.value();
      String reason = responseStatusAnn.reason();
      if (!StringUtils.hasText(reason)) {
        webRequest.getResponse().setStatus(responseStatus.value());
      }
      else {
        webRequest.getResponse().sendError(responseStatus.value(), reason);
View Full Code Here

TOP

Related Classes of org.springframework.web.bind.annotation.ResponseStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.