本文整理汇总了Java中org.springframework.boot.web.servlet.ErrorPageRegistry类的典型用法代码示例。如果您正苦于以下问题:Java ErrorPageRegistry类的具体用法?Java ErrorPageRegistry怎么用?Java ErrorPageRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorPageRegistry类属于org.springframework.boot.web.servlet包,在下文中一共展示了ErrorPageRegistry类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: errorPageRegistrar
import org.springframework.boot.web.servlet.ErrorPageRegistry; //导入依赖的package包/类
/**
* @return Error page registry bean
*/
@Bean
public ErrorPageRegistrar errorPageRegistrar() {
return new ErrorPageRegistrar() {
@Override
public void registerErrorPages(ErrorPageRegistry epr) {
epr.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/not-found"));
epr.addErrorPages(new ErrorPage(HttpStatus.FORBIDDEN, "/error/403"));
epr.addErrorPages(new ErrorPage(HttpStatus.UNAUTHORIZED, "/error/403"));
epr.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500"));
epr.addErrorPages(new ErrorPage(HttpStatus.SERVICE_UNAVAILABLE, "/error/503"));
epr.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/error/400"));
epr.addErrorPages(new ErrorPage(HttpStatus.METHOD_NOT_ALLOWED, "/error/405"));
epr.addErrorPages(new ErrorPage(Exception.class, "/error/500"));
}
};
}
示例2: registerErrorPages
import org.springframework.boot.web.servlet.ErrorPageRegistry; //导入依赖的package包/类
@Override
public void registerErrorPages(@NonNull ErrorPageRegistry registry) {
for (HttpStatus httpStatus : HttpStatus.values()) {
registry.addErrorPages(new ErrorPage(httpStatus,
String.format("/%s/%d", ErrorModule.SERVLET_ERROR_PATH_PREFIX, httpStatus.value())));
}
}
示例3: registerErrorPages
import org.springframework.boot.web.servlet.ErrorPageRegistry; //导入依赖的package包/类
@Override
public void registerErrorPages(ErrorPageRegistry registry) {
registry.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/"));
}
示例4: registerErrorPages
import org.springframework.boot.web.servlet.ErrorPageRegistry; //导入依赖的package包/类
@Override
public void registerErrorPages ( ErrorPageRegistry registry ) {
registry.addErrorPages( new ErrorPage( HttpStatus.NOT_FOUND , "/404.html" ) );
registry.addErrorPages( new ErrorPage( HttpStatus.UNAUTHORIZED , "/401.html" ) );
registry.addErrorPages( new ErrorPage( Throwable.class , "/500.html" ) );
}
示例5: registerErrorPages
import org.springframework.boot.web.servlet.ErrorPageRegistry; //导入依赖的package包/类
@Override
public void registerErrorPages(ErrorPageRegistry errorPageRegistry) {
ErrorPage errorPage = new ErrorPage(this.properties.getServletPrefix()
+ this.properties.getError().getPath());
errorPageRegistry.addErrorPages(errorPage);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:ErrorMvcAutoConfiguration.java
示例6: registerErrorPages
import org.springframework.boot.web.servlet.ErrorPageRegistry; //导入依赖的package包/类
@Override
public void registerErrorPages(ErrorPageRegistry errorPageRegistry) {
errorPageRegistry.addErrorPages(new ErrorPage("/spring/error"));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:5,代码来源:RemappedErrorViewIntegrationTests.java