當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。