public class MyErrorRenderFactory implements IErrorRenderFactory{ public Render getRender(int errorCode, String view) { return new MyErrorRender(errorCode, view); } class MyErrorRender extends ErrorRender { public MyErrorRender(int errorCode, String view) { super(errorCode, view); } public void render() { //这个里面是可以在域中设置一些值的 // request.setAttribute("csspath", "../"); setView("/error/404.html"); super.render(); // RenderFactory.me().getFreeMarkerRender(view).setContext(request, response).render(); } } }
//然后 public void configConstant(Constants me) { me.setErrorRenderFactory(new MyErrorRenderFactory()); }