9dcfaa4380a28963e4a7664b2c496795ff0e2e62.svn-base
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<%
response.setStatus(400);
// 获取异常类
Throwable ex = Exceptions.getThrowable(request);
// 编译错误信息
StringBuilder sb = new StringBuilder("错误信息:\n");
if (ex != null) {
if (ex instanceof BindException) {
for (ObjectError e : ((BindException)ex).getGlobalErrors()){
sb.append("☆" + e.getDefaultMessage() + "(" + e.getObjectName() + ")\n");
}
for (FieldError e : ((BindException)ex).getFieldErrors()){
sb.append("☆" + e.getDefaultMessage() + "(" + e.getField() + ")\n");
}
LoggerFactory.getLogger("400.jsp").warn(ex.getMessage(), ex);
}else if (ex instanceof ConstraintViolationException) {
for (ConstraintViolation<?> v : ((ConstraintViolationException)ex).getConstraintViolations()) {
sb.append("☆" + v.getMessage() + "(" + v.getPropertyPath() + ")\n");
}
} else {
//sb.append(Exceptions.getStackTraceAsString(ex));
sb.append("☆" + ex.getMessage());
}
} else {
sb.append("未知错误.\n\n");
}
// 如果是异步请求或是手机端,则直接返回信息
if (Servlets.isAjaxRequest(request)) {
out.print(sb);
}
// 输出异常信息页面
else {
%>
<%@page import="javax.validation.ConstraintViolation"%>
<%@page import="javax.validation.ConstraintViolationException"%>
<%@page import="org.springframework.validation.BindException"%>
<%@page import="org.springframework.validation.ObjectError"%>
<%@page import="org.springframework.validation.FieldError"%>
<%@page import="org.slf4j.Logger,org.slf4j.LoggerFactory"%>
<%@page import="com.thinkgem.jeesite.common.web.Servlets"%>
<%@page import="com.thinkgem.jeesite.common.utils.Exceptions"%>
<%@page import="com.thinkgem.jeesite.common.utils.StringUtils"%>
<%@page contentType="text/html;charset=UTF-8" isErrorPage="true"%>
<%@include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>400 - 请求出错</title>
<%@include file="/WEB-INF/views/include/head.jsp" %>
</head>
<body>
<div class="container-fluid">
<div class="page-header"><h1>参数有误,服务器无法解析.</h1></div>
<div class="errorMessage">
<%=StringUtils.toHtml(sb.toString())%> <br/>
</div>
<a href="javascript:" onclick="history.go(-1);" class="btn">返回上一页</a>
<br/> <br/>
<script>try{top.$.jBox.closeTip();}catch(e){}</script>
</div>
</body>
</html>
<%
} out = pageContext.pushBody();
%>