错误处理

main
tamguo 7 years ago
parent 7b485edbd8
commit 5002a0e6f3

@ -0,0 +1,21 @@
package com.tamguo.config.web;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
@Component
public class ErrorConfigurar implements ErrorPageRegistrar {
@Override
public void registerErrorPages(ErrorPageRegistry registry) {
ErrorPage[] errorPages=new ErrorPage[2];
errorPages[0]=new ErrorPage(HttpStatus.NOT_FOUND,"/error404");
errorPages[1]=new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/error500");
registry.addErrorPages(errorPages);
}
}

@ -31,5 +31,4 @@ public class WebConfig implements WebMvcConfigurer {
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/files/**").addResourceLocations("file:"+fileStoragePath);
}
}

@ -13,7 +13,7 @@ public class IndexController {
model.setViewName("index");
return model;
}
@RequestMapping(value = "/index", method = RequestMethod.GET)
public ModelAndView mainAction(ModelAndView model) {
model.setViewName("index");
@ -37,4 +37,16 @@ public class IndexController {
model.setViewName("thirdparty/sogousiteverification");
return model;
}
@RequestMapping(value = "error404", method = RequestMethod.GET)
public ModelAndView error404(ModelAndView model) {
model.setViewName("404");
return model;
}
@RequestMapping(value = "error500", method = RequestMethod.GET)
public ModelAndView error500(ModelAndView model) {
model.setViewName("500");
return model;
}
}

@ -1,12 +1,45 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sexbar="http://thymeleafexamples" lang="Zh-hans">
<html lang="Zh-hans" xmlns:th="http://www.thymeleaf.org">
<head>
<title>探果题库_资源不存在</title>
<meta charset="utf-8">
<link type="favicon" rel="shortcut icon" th:href="${domainName + 'images/favicon.png'}" />
<meta name="baidu-site-verification" content="5agfTbCO3Q" />
<meta charset="utf-8" />
<title>探果题库_聪明的学生都在这里</title>
<meta name="keyword" content="探果题库携手高校名师为考生提供高效的智能备考服务,涵括领域有高考、财会类、建筑工程、职业资格、医卫类、计算机类和学历类等热门考试题库。拥有高校名师丰富的经验,优质的学习资料和备考全阶段的高效服务,助您丰富自我,不断前行!"/>
<meta name="description" content="探果题库,高考试题,高考试卷,高校试题,名校,名校试题,名校试卷,高校名师,名师专访,名师教案,名师课堂试题库,试卷库,智能题库,历年真题,模拟试题,押题,预测试题,高考,会计证,会计从业,会计师,经济师,施工员,建造师,建筑师,造价师,职业资格,证券资格,考研,计算机考试,建筑考试,财会类,医卫类,护士资格,公务员,知识点,试题,试卷"/>
<meta name="author" content="Tamguo Team" />
<meta name="copyright" content="Tamguo" />
<meta name="360-site-verification" content="d307dfe5c7562c28c2514592bfba0f58" />
<meta name="wlhlauth" content="6bb48d08d2b053e9e45f91fa46fb0c4f"/>
<link rel="stylesheet" th:href="${domainName + 'css/main.css'}"></link>
<link rel="stylesheet" th:href="${domainName + 'css/reset.css'}" />
<link rel="stylesheet" th:href="${domainName + 'css/iconfont.css'}" />
<link rel="stylesheet" th:href="${domainName + 'css/index.css'}" />
<link rel="stylesheet" th:href="${domainName + 'css/footer.css'}" />
<link rel="stylesheet" th:href="${domainName + 'css/member/minilogin.css'}" />
<link type="favicon" rel="shortcut icon" th:href="${domainName + 'images/favicon.png'}" />
</head>
<body>
访问的内容不存在!
<a th:href="${domainName}">返回首页</a>
<!-- 头部-->
<div th:replace="include/header :: header"></div>
<div class="content-wp">
<div class="main">
<div class="main-container">
访问的内容不存在!
<a th:href="${domainName}">返回首页</a>
</div>
</div>
</div>
<!--尾部-->
<div th:replace="include/footer :: footer"></div>
<!-- 登录 -->
<div th:replace="include/minilogin :: minilogin"></div>
</body>
<script type="text/javascript" src="http://static.tamguo.com/static/js/jquery-1.8.3.min.js" ></script>
<script type="text/javascript" src="http://static.tamguo.com/static/js/jquery.iDialog.js"></script>
<script type="text/javascript" th:src="${domainName + 'js/main.js'}"></script>
<script type="text/javascript" th:src="${domainName + 'js/index.js'}"></script>
<script type="text/javascript" th:src="${domainName + 'js/member/minlogin.js'}"></script>
</html>

@ -1,12 +1,45 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sexbar="http://thymeleafexamples" lang="Zh-hans">
<html lang="Zh-hans" xmlns:th="http://www.thymeleaf.org">
<head>
<title>探果题库_错误页面</title>
<meta charset="utf-8">
<link type="favicon" rel="shortcut icon" th:href="${domainName + 'images/favicon.png'}" />
<meta name="baidu-site-verification" content="5agfTbCO3Q" />
<meta charset="utf-8" />
<title>探果题库_聪明的学生都在这里</title>
<meta name="keyword" content="探果题库携手高校名师为考生提供高效的智能备考服务,涵括领域有高考、财会类、建筑工程、职业资格、医卫类、计算机类和学历类等热门考试题库。拥有高校名师丰富的经验,优质的学习资料和备考全阶段的高效服务,助您丰富自我,不断前行!"/>
<meta name="description" content="探果题库,高考试题,高考试卷,高校试题,名校,名校试题,名校试卷,高校名师,名师专访,名师教案,名师课堂试题库,试卷库,智能题库,历年真题,模拟试题,押题,预测试题,高考,会计证,会计从业,会计师,经济师,施工员,建造师,建筑师,造价师,职业资格,证券资格,考研,计算机考试,建筑考试,财会类,医卫类,护士资格,公务员,知识点,试题,试卷"/>
<meta name="author" content="Tamguo Team" />
<meta name="copyright" content="Tamguo" />
<meta name="360-site-verification" content="d307dfe5c7562c28c2514592bfba0f58" />
<meta name="wlhlauth" content="6bb48d08d2b053e9e45f91fa46fb0c4f"/>
<link rel="stylesheet" th:href="${domainName + 'css/main.css'}"></link>
<link rel="stylesheet" th:href="${domainName + 'css/reset.css'}" />
<link rel="stylesheet" th:href="${domainName + 'css/iconfont.css'}" />
<link rel="stylesheet" th:href="${domainName + 'css/index.css'}" />
<link rel="stylesheet" th:href="${domainName + 'css/footer.css'}" />
<link rel="stylesheet" th:href="${domainName + 'css/member/minilogin.css'}" />
<link type="favicon" rel="shortcut icon" th:href="${domainName + 'images/favicon.png'}" />
</head>
<body>
服务器异常!
<a th:href="${domainName}">返回首页</a>
<!-- 头部-->
<div th:replace="include/header :: header"></div>
<div class="content-wp">
<div class="main">
<div class="main-container">
服务器异常!
<a th:href="${domainName}">返回首页</a>
</div>
</div>
</div>
<!--尾部-->
<div th:replace="include/footer :: footer"></div>
<!-- 登录 -->
<div th:replace="include/minilogin :: minilogin"></div>
</body>
<script type="text/javascript" src="http://static.tamguo.com/static/js/jquery-1.8.3.min.js" ></script>
<script type="text/javascript" src="http://static.tamguo.com/static/js/jquery.iDialog.js"></script>
<script type="text/javascript" th:src="${domainName + 'js/main.js'}"></script>
<script type="text/javascript" th:src="${domainName + 'js/index.js'}"></script>
<script type="text/javascript" th:src="${domainName + 'js/member/minlogin.js'}"></script>
</html>
Loading…
Cancel
Save