exception error

上级 8110d994
......@@ -10,6 +10,7 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
......
......@@ -10,6 +10,7 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
......
package org.maxkey.web;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
* Index
* @author Crystal.Sea
*
*/
@Controller
public class ExceptionEndpoint {
private static Logger _logger = LoggerFactory.getLogger(ExceptionEndpoint.class);
@RequestMapping(value={"/exception/error/400"})
public ModelAndView error400() {
_logger.debug("exception/400.");
return new ModelAndView("exception/400");
}
@RequestMapping(value={"/exception/error/404"})
public ModelAndView error404() {
_logger.debug("exception/404.");
return new ModelAndView("exception/404");
}
@RequestMapping(value={"/exception/error/500"})
public ModelAndView error500() {
_logger.debug("exception/500.");
return new ModelAndView("exception/500");
}
@RequestMapping(value={"/exception/accessdeny"})
public ModelAndView accessdeny() {
_logger.debug("exception/accessdeny.");
return new ModelAndView("exception/accessdeny");
}
}
\ No newline at end of file
......@@ -16,12 +16,14 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/resources">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
......
......@@ -10,6 +10,7 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
......
......@@ -14,10 +14,6 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
package org.maxkey;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
@Configuration
......@@ -19,4 +24,24 @@ public class MaxKeyMgtConfig {
public void setPort(int port) {
this.port = port;
}
/**
* 配置默认错误页面(仅用于内嵌tomcat启动时)
* 使用这种方式,在打包为war后不起作用
*
* @return
*/
@Bean
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
@Override
public void customize(ConfigurableWebServerFactory factory) {
ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST,"/exception/error/400");
ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND,"/exception/error/404");
ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/exception/error/500");
factory.addErrorPages(errorPage400, errorPage404,errorPage500);
}
};
}
}
......@@ -30,16 +30,4 @@ public class IndexEndpoint {
return new ModelAndView("index");
}
@RequestMapping(value={"/accessdeny"})
public ModelAndView accessdeny() {
_logger.debug("exception/accessdeny.");
return new ModelAndView("exception/accessdeny");
}
// @RequestMapping(value={"/error"})
// public ModelAndView error() {
// _logger.debug("exception/error.");
// return new ModelAndView("exception/error");
// }
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<body>
<h1>Page not found!</h1>
</body>
<body>
<h1>REQUEST NOT_FOUND !</h1>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<body>
<h1> INTERNAL_SERVER_ERROR!</h1>
</body>
</html>
\ No newline at end of file
<html>
<body>
<h1>Service Unavailable !</h1>
</body>
</html>
\ No newline at end of file
<html>
<body>
<h1>ERROR!</h1>
</body>
</html>
\ No newline at end of file
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Login Error Page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript">
function autoChangeTime() {
var time = document.getElementById("time").childNodes[0].nodeValue;
var delay = time - 1;
if(delay >0) {
document.getElementById("time").innerHTML = delay;
} else {
document.location.href = "${pageContext.request.contextPath}/login";
return;
}
}
function init() {
window.setInterval('autoChangeTime()','1000');
}
</script>
</head>
<body onload="init()">
<div>
登录失败,失败原因 : ${errorMsg}<br/>
系统将在<span id="time" style="color: red;">5</span>秒后,自动跳转到登录页面,您也可以通过点击<a href="${pageContext.request.contextPath}/login">登录</a>手动跳转
</div>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Oauth Error Page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<div>
oauth认证失败!失败原因 : ${errorMsg}
</div>
</body>
</html>
......@@ -16,14 +16,11 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
......@@ -37,20 +37,20 @@ public class MaxKeyConfig {
return registration;
}
/**
* 配置默认错误页面(仅用于内嵌tomcat启动时)
* 使用这种方式,在打包为war后不起作用
*
* @return
*/
/**
* 配置默认错误页面(仅用于内嵌tomcat启动时)
* 使用这种方式,在打包为war后不起作用
*
* @return
*/
@Bean
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
@Override
public void customize(ConfigurableWebServerFactory factory) {
ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST,"/error-400");
ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND,"/error-404");
ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/error-500");
ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST,"/exception/error/400");
ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND,"/exception/error/404");
ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/exception/error/500");
factory.addErrorPages(errorPage400, errorPage404,errorPage500);
}
......
......@@ -75,10 +75,4 @@ public class IndexEndpoint {
return new ModelAndView("index");
}
@RequestMapping(value={"/accessdeny"})
public ModelAndView accessdeny() {
_logger.debug("exception/accessdeny.");
return new ModelAndView("exception/accessdeny");
}
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<body>
<h1>REQUEST NOT_FOUND !</h1>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<body>
<h1> INTERNAL_SERVER_ERROR!</h1>
</body>
</html>
\ No newline at end of file
<html>
<body>
<h1>Service Unavailable !</h1>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册