本文整理汇总了Java中org.springframework.boot.autoconfigure.web.ErrorAttributes类的典型用法代码示例。如果您正苦于以下问题:Java ErrorAttributes类的具体用法?Java ErrorAttributes怎么用?Java ErrorAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorAttributes类属于org.springframework.boot.autoconfigure.web包,在下文中一共展示了ErrorAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: errorAttributes
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
/**
* Customized ErrorAttribute bean.
* We really need to find a cleaner way of handling these error messages.
*
* @return customized ErrorAttributes
*/
@Bean
public ErrorAttributes errorAttributes() {
return new DefaultErrorAttributes() {
@Override
public Map<String, Object> getErrorAttributes(
final RequestAttributes requestAttributes,
final boolean includeStackTrace) {
Map<String, Object> attributes = super
.getErrorAttributes(requestAttributes, includeStackTrace);
Throwable error = getError(requestAttributes);
if (error instanceof MethodArgumentNotValidException) {
MethodArgumentNotValidException ex =
((MethodArgumentNotValidException) error);
attributes.put("errors", ex.getMessage());
}
return attributes;
}
};
}
示例2: customErrorController
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
/**
* 抄的是{@link ErrorMvcAutoConfiguration#basicErrorController(ErrorAttributes)}
*
* @param errorAttributes
* @return
*/
@Bean
public CustomErrorController customErrorController(ErrorAttributes errorAttributes) {
return new CustomErrorController(
errorAttributes,
this.serverProperties.getError(),
this.errorViewResolvers
);
}
开发者ID:chanjarster,项目名称:spring-mvc-error-handling-example,代码行数:15,代码来源:CustomErrorControllerConfiguration.java
示例3: getErrorData
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Override
public ErrorData getErrorData(BindException ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
String requestUri = getRequestUri(errorAttributes, requestAttributes);
return buildErrorData(ex.getBindingResult())
.withRequestMethod(request.getMethod())
.withRequestUri(requestUri)
.withThrowable(ex)
.build();
}
示例4: getErrorData
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Override
public ErrorData getErrorData(MethodArgumentNotValidException ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
String requestUri = getRequestUri(errorAttributes, requestAttributes);
return buildErrorData(ex.getBindingResult())
.withRequestMethod(request.getMethod())
.withRequestUri(requestUri)
.withThrowable(ex)
.build();
}
开发者ID:mkopylec,项目名称:errorest-spring-boot-starter,代码行数:10,代码来源:MethodArgumentNotValidErrorDataProvider.java
示例5: getErrorData
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Override
public ErrorData getErrorData(T ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
String requestUri = getRequestUri(errorAttributes, requestAttributes);
String requestHeaders = getRequestHeaders(requestAttributes);
return buildErrorData(ex, requestHeaders)
.withRequestMethod(request.getMethod())
.withRequestUri(requestUri)
.build();
}
示例6: getErrorData
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Override
public ErrorData getErrorData(Throwable ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
String requestUri = getRequestUri(errorAttributes, requestAttributes);
return buildErrorData(ex, defaultResponseStatus)
.withRequestMethod(request.getMethod())
.withRequestUri(requestUri)
.withResponseStatus(defaultResponseStatus)
.build();
}
示例7: getErrorData
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Override
public ErrorData getErrorData(T ex, HttpServletRequest request, HttpStatus responseHttpStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
String requestUri = getRequestUri(errorAttributes, requestAttributes);
return buildErrorData(ex, responseHttpStatus)
.withRequestMethod(request.getMethod())
.withRequestUri(requestUri)
.build();
}
示例8: getErrorData
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Override
public ErrorData getErrorData(ExternalHttpRequestException ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
String requestUri = getRequestUri(errorAttributes, requestAttributes);
return buildErrorData(ex, ex.getStatusCode())
.withRequestMethod(request.getMethod())
.withRequestUri(requestUri)
.build();
}
开发者ID:mkopylec,项目名称:errorest-spring-boot-starter,代码行数:9,代码来源:ExternalHttpRequestErrorDataProvider.java
示例9: getErrorData
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Override
public ErrorData getErrorData(ApplicationException ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
String requestUri = getRequestUri(errorAttributes, requestAttributes);
return buildErrorData(ex)
.withRequestMethod(request.getMethod())
.withRequestUri(requestUri)
.build();
}
示例10: ServletFilterErrorHandler
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
public ServletFilterErrorHandler(ErrorAttributes errorAttributes, ServerProperties serverProperties, ErrorsFactory errorsFactory, ErrorDataProviderContext providerContext) {
super(errorAttributes, emptyList());
this.errorAttributes = errorAttributes;
errorProperties = serverProperties.getError();
this.errorsFactory = errorsFactory;
this.providerContext = providerContext;
}
示例11: TraceWebFilterAutoConfiguration
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
public TraceWebFilterAutoConfiguration(TraceRepository traceRepository,
TraceProperties traceProperties,
ObjectProvider<ErrorAttributes> errorAttributesProvider) {
this.traceRepository = traceRepository;
this.traceProperties = traceProperties;
this.errorAttributes = errorAttributesProvider.getIfAvailable();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:TraceWebFilterAutoConfiguration.java
示例12: customizeErrorResponseAttributes
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Bean
public ErrorAttributes customizeErrorResponseAttributes() {
return new DefaultErrorAttributes(){
@Override
public Map<String, Object> getErrorAttributes(RequestAttributes requestAttributes, boolean includeStackTrace) {
Map<String, Object> errorAttributes = super.getErrorAttributes(requestAttributes, includeStackTrace);
errorAttributes.remove("timestamp");
errorAttributes.remove("exception");
return errorAttributes;
}
};
}
示例13: errorEndpoint
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Bean
@ConditionalOnBean(ErrorAttributes.class)
public ManagementErrorEndpoint errorEndpoint(ServerProperties serverProperties,
ErrorAttributes errorAttributes) {
return new ManagementErrorEndpoint(serverProperties.getError().getPath(),
errorAttributes);
}
示例14: before
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Before
public void before() {
this.errorAttributes = mock(ErrorAttributes.class);
Map<String, Object> result = new HashMap<>();
result.put("exception", "exception");
result.put("message", "message");
when(errorAttributes.getErrorAttributes(any(), anyBoolean())).thenReturn(result);
this.subject = new ErrorController(errorAttributes);
}
示例15: errorAttributes
import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Bean
public ErrorAttributes errorAttributes() {
// override boot's DefaultErrorAttributes
return new SkipperErrorAttributes();
}