本文整理汇总了Java中org.springframework.http.ResponseEntity.BodyBuilder类的典型用法代码示例。如果您正苦于以下问题:Java BodyBuilder类的具体用法?Java BodyBuilder怎么用?Java BodyBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BodyBuilder类属于org.springframework.http.ResponseEntity包,在下文中一共展示了BodyBuilder类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processHttpServerError
import org.springframework.http.ResponseEntity.BodyBuilder; //导入依赖的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.BodyBuilder; //导入依赖的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.BodyBuilder; //导入依赖的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: processException
import org.springframework.http.ResponseEntity.BodyBuilder; //导入依赖的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
示例5: processRuntimeException
import org.springframework.http.ResponseEntity.BodyBuilder; //导入依赖的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
示例6: processRuntimeException
import org.springframework.http.ResponseEntity.BodyBuilder; //导入依赖的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.BodyBuilder; //导入依赖的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.BodyBuilder; //导入依赖的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.BodyBuilder; //导入依赖的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:mraible,项目名称:devoxxus-jhipster-microservices-demo,代码行数:15,代码来源:ExceptionTranslator.java
示例10: processException
import org.springframework.http.ResponseEntity.BodyBuilder; //导入依赖的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:alikemalocalan,项目名称:MicroBlog,代码行数:20,代码来源:ExceptionTranslator.java
示例11: processRuntimeException
import org.springframework.http.ResponseEntity.BodyBuilder; //导入依赖的package包/类
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) throws Exception {
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:axel-halin,项目名称:Thesis-JHipster,代码行数:15,代码来源:ExceptionTranslator.java
注:本文中的org.springframework.http.ResponseEntity.BodyBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论