关键内容
- mvc-chain.js
- ViewProcessor
- ai.setFailView(“redirect:/sysError.html”);
- log.error(this.trrowableToString(ac.getError()));
首先,在mvc-chain.js中配置系统异常处理类
var chain={
"default" : {
"ps" : [
"com.carforu.processor.SystemLogProcessor",
"org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor", "org.nutz.mvc.impl.processor.EncodingProcessor", "org.nutz.mvc.impl.processor.ModuleProcessor", "org.nutz.integration.shiro.NutShiroProcessor",
"org.nutz.mvc.impl.processor.ActionFiltersProcessor",
"org.nutz.mvc.impl.processor.AdaptorProcessor",
"org.nutz.mvc.impl.processor.MethodInvokeProcessor",
"org.nutz.mvc.impl.processor.ViewProcessor"
],
"error" : 'com.carforu.data.SysUncaughtException'
}
};
然后自己写一个实例继承ViewProcessor
最后在它的方法中设置自己的错误提示页面
public void init(NutConfig config, ActionInfo ai) throws Throwable {
ai.setFailView("redirect:/sysError.html");
view = evalView(config, ai, ai.getFailView());
}