Controller在执行的过程中,可能会报错,这个时候应该统一给 前台反馈“服务器出现异常,请重试”等个性化ajax提示。
com.jfinal.core.ActionHandler
默认都自己处理了,没有留扩展吗?
catch (RenderException e) {
if (log.isErrorEnabled()) {
String qs = request.getQueryString();
log.error(qs == null ? target : target + "?" + qs, e);
}
}
catch (ActionException e) {
int errorCode = e.getErrorCode();
String msg = null;
if (errorCode == 404) {
msg = "404 Not Found: ";
} else if (errorCode == 401) {
msg = "401 Unauthorized: ";
} else if (errorCode == 403) {
msg = "403 Forbidden: ";
}
if (msg != null) {
if (log.isWarnEnabled()) {
String qs = request.getQueryString();
log.warn(msg + (qs == null ? target : target + "?" + qs));
}
} else {
if (log.isErrorEnabled()) {
String qs = request.getQueryString();
log.error(qs == null ? target : target + "?" + qs, e);
}
}
e.getErrorRender().setContext(request, response, action.getViewPath()).render();
}
catch (Exception e) {
if (log.isErrorEnabled()) {
String qs = request.getQueryString();
log.error(qs == null ? target : target + "?" + qs, e);
}
renderManager.getRenderFactory().getErrorRender(500).setContext(request, response, action.getViewPath()).render();
} finally {
if (controller != null) {
controller.clear();
}
}
try {
inv.invoke();
}
catch(Exception e) {
inv.getController().renderJson(....);
}