org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TacoCloudApplication.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@Bean
ErrorViewResolver supportPathBasedLocationStrategyWithoutHashes() {
    return new ErrorViewResolver() {
        @Override
        public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
            return status == HttpStatus.NOT_FOUND
                    ? new ModelAndView("index.html", Collections.<String, Object>emptyMap(), HttpStatus.OK)
                    : null;
        }
    };
}
 
Example #2
Source File: TacoCloudApplication.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@Bean
ErrorViewResolver supportPathBasedLocationStrategyWithoutHashes() {
    return new ErrorViewResolver() {
        @Override
        public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
            return status == HttpStatus.NOT_FOUND
                    ? new ModelAndView("index.html", Collections.<String, Object>emptyMap(), HttpStatus.OK)
                    : null;
        }
    };
}
 
Example #3
Source File: TacoCloudApplication.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@Bean
ErrorViewResolver supportPathBasedLocationStrategyWithoutHashes() {
    return new ErrorViewResolver() {
        @Override
        public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
            return status == HttpStatus.NOT_FOUND
                    ? new ModelAndView("index.html", Collections.<String, Object>emptyMap(), HttpStatus.OK)
                    : null;
        }
    };
}
 
Example #4
Source File: TacoCloudApplication.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@Bean
ErrorViewResolver supportPathBasedLocationStrategyWithoutHashes() {
    return new ErrorViewResolver() {
        @Override
        public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
            return status == HttpStatus.NOT_FOUND
                    ? new ModelAndView("index.html", Collections.<String, Object>emptyMap(), HttpStatus.OK)
                    : null;
        }
    };
}
 
Example #5
Source File: TacoCloudApplication.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@Bean
ErrorViewResolver supportPathBasedLocationStrategyWithoutHashes() {
    return new ErrorViewResolver() {
        @Override
        public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
            return status == HttpStatus.NOT_FOUND
                    ? new ModelAndView("index.html", Collections.<String, Object>emptyMap(), HttpStatus.OK)
                    : null;
        }
    };
}
 
Example #6
Source File: TacoCloudApplication.java    From spring-in-action-5-samples with Apache License 2.0 5 votes vote down vote up
@Bean
ErrorViewResolver supportPathBasedLocationStrategyWithoutHashes() {
    return new ErrorViewResolver() {
        @Override
        public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
            return status == HttpStatus.NOT_FOUND
                    ? new ModelAndView("index.html", Collections.<String, Object>emptyMap(), HttpStatus.OK)
                    : null;
        }
    };
}
 
Example #7
Source File: ServletErrorsAutoConfiguration.java    From errors-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
/**
 * Registers a custom {@link ErrorController} to change the default error handling approach.
 *
 * @param errorAttributes    Will be used to enrich error responses.
 * @param serverProperties   Will be used to access error related configurations.
 * @param errorViewResolvers All possible view resolvers to render the whitelabel error page.
 * @return The custom error controller instance.
 */
@Bean
@ConditionalOnBean(WebErrorHandlers.class)
@ConditionalOnMissingBean(ErrorController.class)
public BasicErrorController customErrorController(ErrorAttributes errorAttributes,
                                             ServerProperties serverProperties,
                                             ObjectProvider<ErrorViewResolver> errorViewResolvers) {
    List<ErrorViewResolver> resolvers = errorViewResolvers.orderedStream().collect(toList());
    return new CustomServletErrorController(errorAttributes, serverProperties.getError(), resolvers);
}
 
Example #8
Source File: ServletErrorsAutoConfiguration.java    From errors-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
public CustomServletErrorController(ErrorAttributes errorAttributes,
                                    ErrorProperties errorProperties,
                                    List<ErrorViewResolver> resolvers) {
    super(errorAttributes, errorProperties, resolvers);
}
 
Example #9
Source File: ErrorPageController.java    From Microservices-with-Spring-Cloud with MIT License 4 votes vote down vote up
public ErrorPageController(ErrorAttributes errorAttributes, List<ErrorViewResolver> errorViewResolvers) {
    super(errorAttributes, errorViewResolvers);
}
 
Example #10
Source File: CrnkErrorControllerAutoConfiguration.java    From crnk-framework with Apache License 2.0 4 votes vote down vote up
public CrnkErrorControllerAutoConfiguration(ServerProperties serverProperties,
											ObjectProvider<List<ErrorViewResolver>> errorViewResolversProvider) {
	this.serverProperties = serverProperties;
	this.errorViewResolvers = errorViewResolversProvider.getIfAvailable();
}
 
Example #11
Source File: CrnkErrorController.java    From crnk-framework with Apache License 2.0 4 votes vote down vote up
public CrnkErrorController(ErrorAttributes errorAttributes,
						   ErrorProperties errorProperties,
						   List<ErrorViewResolver> errorViewResolvers) {
	super(errorAttributes, errorProperties, errorViewResolvers);
}
 
Example #12
Source File: MetacatErrorController.java    From metacat with Apache License 2.0 2 votes vote down vote up
/**
 * Default constructor.
 * @param errorAttributes error attributes
 * @param errorProperties error properties
 */
public MetacatErrorController(final ErrorAttributes errorAttributes, final ErrorProperties errorProperties) {
    super(errorAttributes, Collections.<ErrorViewResolver>emptyList());
    this.errorProperties = errorProperties;
}