ajax获取后端抛出的异常
if (user.name == null || user.name.isEmpty()) {
throw new RuntimeException("name is null");
}
这是我后端抛出的异常;
错误信息:{"timestamp":1536635826000,"status":500,"error":"Internal Server Error","exception":"java.lang.RuntimeException","message":"nama is exist","path":"/users"}
前端ajax获取的异常能不能只要message里面的信息,请问我的ajax需要怎么改
ajax代码:
$.ajax({
url: "http://localhost:8080/users",
type: "POST",
dataType: "json",
//
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("错误信息:" + XMLHttpRequest.responseText);},
headers: {
"Content-Type": "application/json"
},
data: JSON.stringify(obj),
cache: false,
success: function (data) {
alert("添加成功");
getAll();
}
});
throw new RuntimeException("name is null");
}
这是我后端抛出的异常;
错误信息:{"timestamp":1536635826000,"status":500,"error":"Internal Server Error","exception":"java.lang.RuntimeException","message":"nama is exist","path":"/users"}
前端ajax获取的异常能不能只要message里面的信息,请问我的ajax需要怎么改
ajax代码:
$.ajax({
url: "http://localhost:8080/users",
type: "POST",
dataType: "json",
//
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("错误信息:" + XMLHttpRequest.responseText);},
headers: {
"Content-Type": "application/json"
},
data: JSON.stringify(obj),
cache: false,
success: function (data) {
alert("添加成功");
getAll();
}
});
...全文
相关推荐
有关ajax的error与后台的异常问题解决
主要介绍了关于ajax的error与后台的异常,需要的朋友可以参考下
关于Ajax中通过response在后台传递数据问题
给大家介绍了Ajax中通过response在后台传递数据问题,需要的的朋友参考下吧
lotus domino AJAX json获取视图列重要说明
lotus domino AJAX json获取视图列重要说明
ajax传输json出错问题
前端利用ajax请求传输json串出错
PHP ajax 分页代码类
一个php ajax分页类,本分页类不处理SQL,大大的加快了分页功能,设定类中指定变量名的值,如果改变量不属于这个类,将throw一个exception 。


