### Question:
BaseController { protected ModelAndView handleAjaxException(AjaxException ae, HttpServletResponse res) { AjaxError ajaxError = ae.getAjaxError(); ajaxError.addDetailMsg(getMessage(ae)); outWriteJSON(res, ajaxError.toString()); return null; }  @ExceptionHandler(Exception.class) ModelAndView handleException(Exception ex, HttpServletRequest req, HttpServletResponse res);  }### Answer:
@Test public void testHandleAjaxException() throws Exception { HttpResponse response = executeGet("/test/ajaxExp"); Assert.assertEquals("Ajax异常捕获失败！", 500, response.getStatusLine().getStatusCode()); String json = EntityUtils.toString(response.getEntity(), defaultEncode); JSONObject jsonObject = JSONObject.fromObject(json); String detail = jsonObject.getJSONObject("msg").getString("detail"); Assert.assertTrue("Ajax异常捕获失败！", detail.contains("测试Ajax异常")); }