Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Spring处理AJAX错误_Ajax_Spring_Web.xml - Fatal编程技术网

使用Spring处理AJAX错误

使用Spring处理AJAX错误,ajax,spring,web.xml,Ajax,Spring,Web.xml,我在我的项目中使用AJAX。在这里,我捕捉错误,它将弹出警报。但我想使用Spring(web.xml)处理xhr错误。可能吗?我该怎么做呢 “使用web.xml”的最终结果是什么?我想加载错误页面。不是警报。只需重定向到错误页面,而不是显示警报。 error: function(xhr, exception) { if (xhr.status === 0) { alert('Not connect.\n Verify Network.'); } else

我在我的项目中使用AJAX。在这里,我捕捉错误,它将弹出警报。但我想使用Spring(web.xml)处理xhr错误。可能吗?我该怎么做呢

“使用web.xml”的最终结果是什么?我想加载错误页面。不是警报。只需重定向到错误页面,而不是显示警报。
 error: function(xhr, exception) {
    if (xhr.status === 0) {
        alert('Not connect.\n Verify Network.');
        } else if (xhr.status == 404) {
        alert('Requested page not found. [404]');
        } else if (xhr.status == 500) {
        alert('Internal Server Error [500].');
        } else if (exception === 'parsererror') {
        alert('Requested JSON parse failed.');
        } else if (exception === 'timeout') {
        alert('Time out error.');
        } else if (exception === 'abort') {
        alert('Ajax request aborted.');
        } else {
        alert('Uncaught Error.\n');
    }
}