当前位置: 首页>>代码示例>>Java>>正文


Java ErrorAttributes类代码示例

本文整理汇总了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;
		}
	};
}
 
开发者ID:ssherwood,项目名称:spring-boot-jpa,代码行数:29,代码来源:BootJpaApplication.java

示例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();
}
 
开发者ID:mkopylec,项目名称:errorest-spring-boot-starter,代码行数:10,代码来源:BindExceptionErrorDataProvider.java

示例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();
}
 
开发者ID:mkopylec,项目名称:errorest-spring-boot-starter,代码行数:10,代码来源:SecurityErrorDataProvider.java

示例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();
}
 
开发者ID:mkopylec,项目名称:errorest-spring-boot-starter,代码行数:10,代码来源:ThrowableErrorDataProvider.java

示例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();
}
 
开发者ID:mkopylec,项目名称:errorest-spring-boot-starter,代码行数:9,代码来源:HttpClientErrorDataProvider.java

示例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();
}
 
开发者ID:mkopylec,项目名称:errorest-spring-boot-starter,代码行数:9,代码来源:ApplicationErrorDataProvider.java

示例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;
}
 
开发者ID:mkopylec,项目名称:errorest-spring-boot-starter,代码行数:8,代码来源:ServletFilterErrorHandler.java

示例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;
        }
    };
    
}
 
开发者ID:quebic-source,项目名称:searchbox-core,代码行数:15,代码来源:SearchBoxConfiguration.java

示例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);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:8,代码来源:EndpointWebMvcChildContextConfiguration.java

示例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);
}
 
开发者ID:OpenConext,项目名称:OpenConext-pdp,代码行数:13,代码来源:ErrorControllerTest.java

示例15: errorAttributes

import org.springframework.boot.autoconfigure.web.ErrorAttributes; //导入依赖的package包/类
@Bean
public ErrorAttributes errorAttributes() {
	// override boot's DefaultErrorAttributes
	return new SkipperErrorAttributes();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:6,代码来源:SkipperServerConfiguration.java


注:本文中的org.springframework.boot.autoconfigure.web.ErrorAttributes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。