Explorar o código

exception error

shimingxy %!s(int64=5) %!d(string=hai) anos
pai
achega
b7a0ecddc0
Modificáronse 27 ficheiros con 125 adicións e 109 borrados
  1. 1 0
      maxkey-client-sdk/.classpath
  2. 1 0
      maxkey-core/.classpath
  3. 39 0
      maxkey-core/src/main/java/org/maxkey/web/ExceptionEndpoint.java
  4. 2 0
      maxkey-dao/.classpath
  5. 1 0
      maxkey-protocols/maxkey-protocol-cas/.classpath
  6. 1 5
      maxkey-web-manage/.classpath
  7. 25 0
      maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java
  8. 0 12
      maxkey-web-manage/src/main/java/org/maxkey/web/endpoint/IndexEndpoint.java
  9. 1 1
      maxkey-web-manage/src/main/resources/templates/views/exception/400.ftl
  10. 4 3
      maxkey-web-manage/src/main/resources/templates/views/exception/404.ftl
  11. 6 0
      maxkey-web-manage/src/main/resources/templates/views/exception/500.ftl
  12. 5 0
      maxkey-web-manage/src/main/resources/templates/views/exception/501.ftl
  13. 5 0
      maxkey-web-manage/src/main/resources/templates/views/exception/503.ftl
  14. 0 5
      maxkey-web-manage/src/main/resources/templates/views/exception/error.ftl
  15. 0 34
      maxkey-web-manage/src/main/resources/templates/views/exception/loginError.ftl
  16. 0 18
      maxkey-web-manage/src/main/resources/templates/views/exception/oauthError.ftl
  17. 2 5
      maxkey-web-maxkey/.classpath
  18. 9 9
      maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java
  19. 0 6
      maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/IndexEndpoint.java
  20. 1 1
      maxkey-web-maxkey/src/main/resources/templates/views/exception/400.ftl
  21. 6 0
      maxkey-web-maxkey/src/main/resources/templates/views/exception/404.ftl
  22. 6 0
      maxkey-web-maxkey/src/main/resources/templates/views/exception/500.ftl
  23. 5 0
      maxkey-web-maxkey/src/main/resources/templates/views/exception/501.ftl
  24. 0 5
      maxkey-web-maxkey/src/main/resources/templates/views/exception/501.jsp
  25. 5 0
      maxkey-web-maxkey/src/main/resources/templates/views/exception/503.ftl
  26. 0 5
      maxkey-web-maxkey/src/main/resources/templates/views/exception/503.jsp
  27. 0 0
      maxkey-web-maxkey/src/main/resources/templates/views/exception/accessdeny.ftl

+ 1 - 0
maxkey-client-sdk/.classpath

@@ -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/"/>

+ 1 - 0
maxkey-core/.classpath

@@ -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/"/>

+ 39 - 0
maxkey-core/src/main/java/org/maxkey/web/ExceptionEndpoint.java

@@ -0,0 +1,39 @@
+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");
+	}
+}

+ 2 - 0
maxkey-dao/.classpath

@@ -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/"/>

+ 1 - 0
maxkey-protocols/maxkey-protocol-cas/.classpath

@@ -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/"/>

+ 1 - 5
maxkey-web-manage/.classpath

@@ -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>

+ 25 - 0
maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java

@@ -1,8 +1,13 @@
 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);
+
+            }
+        };
+	}
 }

+ 0 - 12
maxkey-web-manage/src/main/java/org/maxkey/web/endpoint/IndexEndpoint.java

@@ -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");
-//	}
 }

+ 1 - 1
maxkey-web-maxkey/src/main/resources/templates/views/exception/500.jsp → maxkey-web-manage/src/main/resources/templates/views/exception/400.ftl

@@ -1,6 +1,6 @@
 <!DOCTYPE html>
 <html>
 	<body>
-		<h1>Error!</h1>
+		<h1>BAD_REQUEST!</h1>
 	</body>
 </html>

+ 4 - 3
maxkey-web-manage/src/main/resources/templates/views/exception/404.ftl

@@ -1,5 +1,6 @@
+<!DOCTYPE html>
 <html>
-<body>
-<h1>Page not found!</h1>
-</body>
+	<body>
+		<h1>REQUEST NOT_FOUND !</h1>
+	</body>
 </html>

+ 6 - 0
maxkey-web-manage/src/main/resources/templates/views/exception/500.ftl

@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+	<body>
+		<h1> INTERNAL_SERVER_ERROR!</h1>
+	</body>
+</html>

+ 5 - 0
maxkey-web-manage/src/main/resources/templates/views/exception/501.ftl

@@ -0,0 +1,5 @@
+<html>
+	<body>
+		<h1>Not Implemented !</h1>
+	</body>
+</html>

+ 5 - 0
maxkey-web-manage/src/main/resources/templates/views/exception/503.ftl

@@ -0,0 +1,5 @@
+<html>
+	<body>
+		<h1>Service Unavailable !</h1>
+	</body>
+</html>

+ 0 - 5
maxkey-web-manage/src/main/resources/templates/views/exception/error.ftl

@@ -1,5 +0,0 @@
-<html>
-<body>
-<h1>ERROR!</h1>
-</body>
-</html>

+ 0 - 34
maxkey-web-manage/src/main/resources/templates/views/exception/loginError.ftl

@@ -1,34 +0,0 @@
-<%@ 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>

+ 0 - 18
maxkey-web-manage/src/main/resources/templates/views/exception/oauthError.ftl

@@ -1,18 +0,0 @@
-<%@ 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>

+ 2 - 5
maxkey-web-maxkey/.classpath

@@ -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>

+ 9 - 9
maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java

@@ -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);
 
             }

+ 0 - 6
maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/IndexEndpoint.java

@@ -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");
-	}
 }

+ 1 - 1
maxkey-web-maxkey/src/main/resources/templates/views/exception/404.jsp → maxkey-web-maxkey/src/main/resources/templates/views/exception/400.ftl

@@ -1,6 +1,6 @@
 <!DOCTYPE html>
 <html>
 	<body>
-		<h1>Error!</h1>
+		<h1>BAD_REQUEST!</h1>
 	</body>
 </html>

+ 6 - 0
maxkey-web-maxkey/src/main/resources/templates/views/exception/404.ftl

@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+	<body>
+		<h1>REQUEST NOT_FOUND !</h1>
+	</body>
+</html>

+ 6 - 0
maxkey-web-maxkey/src/main/resources/templates/views/exception/500.ftl

@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+	<body>
+		<h1> INTERNAL_SERVER_ERROR!</h1>
+	</body>
+</html>

+ 5 - 0
maxkey-web-maxkey/src/main/resources/templates/views/exception/501.ftl

@@ -0,0 +1,5 @@
+<html>
+	<body>
+		<h1>Not Implemented !</h1>
+	</body>
+</html>

+ 0 - 5
maxkey-web-maxkey/src/main/resources/templates/views/exception/501.jsp

@@ -1,5 +0,0 @@
-<html>
-	<body>
-		<h1>Error!</h1>
-	</body>
-</html>

+ 5 - 0
maxkey-web-maxkey/src/main/resources/templates/views/exception/503.ftl

@@ -0,0 +1,5 @@
+<html>
+	<body>
+		<h1>Service Unavailable !</h1>
+	</body>
+</html>

+ 0 - 5
maxkey-web-maxkey/src/main/resources/templates/views/exception/503.jsp

@@ -1,5 +0,0 @@
-<html>
-	<body>
-		<h1>Error!</h1>
-	</body>
-</html>

+ 0 - 0
maxkey-web-maxkey/src/main/resources/templates/views/exception/accessdeny.jsp → maxkey-web-maxkey/src/main/resources/templates/views/exception/accessdeny.ftl