ajax请求异常捕获的问题
在getAjacError方法里面除0操作,跑到ajacError.js里面,直接就进了error,无法请求成功??
在getAjacError方法里面除0操作,跑到ajacError.js里面,直接就进了error,无法请求成功??
2018-09-20
@ExceptionHandler(value = Exception.class) public void exceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception e, Model model) throws Exception { if (isAjax(request)) { // 向response中写json数据 response.setCharacterEncoding("utf-8"); response.setContentType("application/json; charset=utf-8"); PrintWriter writer = response.getWriter(); writer.write(gson.toJson(JsonResult.errorException(e.getMessage()))); } else { request.setAttribute("exception", e); request.setAttribute("url", request.getRequestURL()); request.getRequestDispatcher("/templates/error.html").forward(request, response); } }
已根据@玩蜡笔小破孩同学的方法解决了问题,感谢
举报