當前位置: 首頁>>代碼示例>>Java>>正文


Java ResponseEntity.status方法代碼示例

本文整理匯總了Java中org.springframework.http.ResponseEntity.status方法的典型用法代碼示例。如果您正苦於以下問題:Java ResponseEntity.status方法的具體用法?Java ResponseEntity.status怎麽用?Java ResponseEntity.status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.http.ResponseEntity的用法示例。


在下文中一共展示了ResponseEntity.status方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processHttpServerError

import org.springframework.http.ResponseEntity; //導入方法依賴的package包/類
@ExceptionHandler(HttpServerErrorException.class)
@ResponseBody
public ResponseEntity<ErrorVM> processHttpServerError(HttpServerErrorException ex) {
    BodyBuilder builder;
    ErrorVM fieldErrorVM;
    HttpStatus responseStatus = ex.getStatusCode();
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        fieldErrorVM = new ErrorVM(ERROR_PREFIX + responseStatus.value(), translate(ERROR_PREFIX
                                                                                        + responseStatus.value()));
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        fieldErrorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR,
                                   translate(ErrorConstants.ERR_INTERNAL_SERVER_ERROR));
    }
    return builder.body(fieldErrorVM);
}
 
開發者ID:xm-online,項目名稱:xm-commons,代碼行數:18,代碼來源:ExceptionTranslator.java

示例2: processException

import org.springframework.http.ResponseEntity; //導入方法依賴的package包/類
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorVM> processException(Exception ex) {
    log.error("An unexpected error occurred: {}", ex.getMessage(), ex);
    BodyBuilder builder;
    ErrorVM errorVM;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        errorVM = new ErrorVM(ERROR_PREFIX + responseStatus.value().value(),
                              translate(ERROR_PREFIX + responseStatus.value().value()));
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR,
                              translate(ErrorConstants.ERR_INTERNAL_SERVER_ERROR));
    }
    return builder.body(errorVM);
}
 
開發者ID:xm-online,項目名稱:xm-commons,代碼行數:18,代碼來源:ExceptionTranslator.java

示例3: processException

import org.springframework.http.ResponseEntity; //導入方法依賴的package包/類
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorVM> processException(Exception ex) {
    if (log.isDebugEnabled()) {
        log.debug("An unexpected error occurred: {}", ex.getMessage(), ex);
    } else {
        log.error("An unexpected error occurred: {}", ex.getMessage());
    }
    BodyBuilder builder;
    ErrorVM errorVM;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason());
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error");
    }
    return builder.body(errorVM);
}
 
開發者ID:michaelhoffmantech,項目名稱:patient-portal,代碼行數:20,代碼來源:ExceptionTranslator.java

示例4: processRuntimeException

import org.springframework.http.ResponseEntity; //導入方法依賴的package包/類
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception {
    BodyBuilder builder;
    ErrorDTO errorDTO;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason());
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error");
    }
    log.error("Exception in rest call", ex);
    errorDTO.add("error", "error", ex.getMessage());
    return builder.body(errorDTO);
}
 
開發者ID:klask-io,項目名稱:klask-io,代碼行數:17,代碼來源:ExceptionTranslator.java

示例5: processException

import org.springframework.http.ResponseEntity; //導入方法依賴的package包/類
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorVM> processException(Exception ex) {
    if (log.isDebugEnabled()) {
        log.debug("An unexpected error occured: {}", ex.getMessage(), ex);
    } else {
        log.error("An unexpected error occured: {}", ex.getMessage());
    }
    BodyBuilder builder;
    ErrorVM errorVM;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason());
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error");
    }
    return builder.body(errorVM);
}
 
開發者ID:oktadeveloper,項目名稱:jhipster-microservices-example,代碼行數:20,代碼來源:ExceptionTranslator.java

示例6: processRuntimeException

import org.springframework.http.ResponseEntity; //導入方法依賴的package包/類
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) {
    BodyBuilder builder;
    ErrorVM errorVM;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason());
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error");
    }
    return builder.body(errorVM);
}
 
開發者ID:oktadeveloper,項目名稱:jhipster-microservices-example,代碼行數:15,代碼來源:ExceptionTranslator.java

示例7: processRuntimeException

import org.springframework.http.ResponseEntity; //導入方法依賴的package包/類
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) {
    log.debug("Processing runtime exception", ex);
    BodyBuilder builder;
    ErrorVM errorVM;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason());
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error");
    }
    return builder.body(errorVM);
}
 
開發者ID:quanticc,項目名稱:sentry,代碼行數:16,代碼來源:ExceptionTranslator.java

示例8: processException

import org.springframework.http.ResponseEntity; //導入方法依賴的package包/類
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorVM> processException(Exception ex) {
    log.error(ex.getMessage(), ex);
    BodyBuilder builder;
    ErrorVM errorVM;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        errorVM = new ErrorVM("error." + responseStatus.value().value(), responseStatus.reason());
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        errorVM = new ErrorVM(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error");
    }
    return builder.body(errorVM);
}
 
開發者ID:deepu105,項目名稱:spring-io,代碼行數:16,代碼來源:ExceptionTranslator.java

示例9: processRuntimeException

import org.springframework.http.ResponseEntity; //導入方法依賴的package包/類
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception {
    BodyBuilder builder;
    ErrorDTO errorDTO;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason());
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error");
    }
    return builder.body(errorDTO);
}
 
開發者ID:IBM,項目名稱:Microservices-with-JHipster-and-Spring-Boot,代碼行數:15,代碼來源:ExceptionTranslator.java

示例10: buildStatus

import org.springframework.http.ResponseEntity; //導入方法依賴的package包/類
private static ResponseEntity.BodyBuilder buildStatus ( int status ) {
	return ResponseEntity.status( status );
}
 
開發者ID:yujunhao8831,項目名稱:spring-boot-start-current,代碼行數:4,代碼來源:ResponseEntityPro.java


注:本文中的org.springframework.http.ResponseEntity.status方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。