默认的返回消息是Error
如果希望自定义处理错误消息,可以使用元数据的方式调用
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/util.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/interface/MyDwr.js"></script>
<script type="text/javascript">
MyDwr.deleteUser({
callback:deleteUser,
errorHandler:function(msg,exception) {
alert(msg);
/*for(var ea in exception) {
alert(ea);
}
alert(exception.stackTrace);*/
alert(dwr.util.toDescriptiveString(exception,1));
}
});
function deleteUser(data) {
}
</script>
</head>
<body>
</body>
</html>
可以开启异常的转换(在dwr.xml中配置)
<convert match="java.lang.Exception" converter="exception"/>
<convert converter="bean" match="java.lang.StackTraceElement"/>
按照以上步骤做了之后就可以获取完整的异常出错信息