Compare commits

..

No commits in common. '06d9bb5e67c7325718b94d363327fb3690897049' and 'b37efb50cc8f57f995feeb6c8fe08cf49f4729d7' have entirely different histories.

@ -6,33 +6,16 @@ import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
/**
* ErrorPageRegistrar
*/
@Component
public class ErrorConfigurar implements ErrorPageRegistrar {
/**
*
*
* @param registry
*/
@Override
public void registerErrorPages(ErrorPageRegistry registry) {
// 创建一个错误页面数组
ErrorPage[] errorPages = new ErrorPage[2];
ErrorPage[] errorPages=new ErrorPage[2];
errorPages[0]=new ErrorPage(HttpStatus.NOT_FOUND,"/error404");
errorPages[1]=new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/error500");
// 创建一个表示 404 状态的错误页面,并指定其重定向路径
ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/error404");
// 创建一个表示 500 状态的错误页面,并指定其重定向路径
ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error500");
// 将两个错误页面添加到错误页面数组中
errorPages[0] = errorPage404;
errorPages[1] = errorPage500;
// 将错误页面数组添加到错误页面注册表中
registry.addErrorPages(errorPages);
registry.addErrorPages(errorPages);
}
}
}

Loading…
Cancel
Save