本文整理汇总了Java中com.jfinal.render.RenderFactory类的典型用法代码示例。如果您正苦于以下问题:Java RenderFactory类的具体用法?Java RenderFactory怎么用?Java RenderFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RenderFactory类属于com.jfinal.render包,在下文中一共展示了RenderFactory类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import com.jfinal.render.RenderFactory; //导入依赖的package包/类
public void render() {
// render with view
String view = getView();
if (view != null) {
RenderFactory.me().getRender(view).setContext(request, response).render();
return;
}
// render with html content
PrintWriter writer = null;
try {
response.setContentType(contentType);
writer = response.getWriter();
writer.write(getErrorHtml().toJson());
writer.flush();
} catch (IOException e) {
throw new RenderException(e);
} finally {
if (writer != null)
writer.close();
}
}
示例2: handle
import com.jfinal.render.RenderFactory; //导入依赖的package包/类
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
if (!target.startsWith("/api")) {
this.nextHandler.handle(target, request, response, isHandled);
return;
}
if (JFinal.me().getAction(target, new String[1]) == null) {
isHandled[0] = true;
try {
request.setCharacterEncoding("utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
RenderFactory.me().getJsonRender(new BaseResponse(Code.NOT_FOUND, "resource is not found")).setContext(request, response).render();
} else {
this.nextHandler.handle(target, request, response, isHandled);
}
}
示例3: render
import com.jfinal.render.RenderFactory; //导入依赖的package包/类
public void render() {
response.setStatus(getErrorCode()); // HttpServletResponse.SC_XXX_XXX
// render with view
String view = getView();
if (view != null) {
RenderFactory.me().getRender(view).setContext(request, response).render();
return;
}
// render with html content
PrintWriter writer = null;
try {
response.setContentType(contentType);
writer = response.getWriter();
writer.write(getErrorHtml());
writer.flush();
} catch (IOException e) {
throw new RenderException(e);
} finally {
if (writer != null) {
writer.close();
}
}
}
示例4: handle
import com.jfinal.render.RenderFactory; //导入依赖的package包/类
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
if (checkView(target)) {
isHandled[0] = true;
RenderFactory.me().getErrorRender(403).setContext(request, response).render();
return;
}
next.handle(target, request, response, isHandled);
}
示例5: render
import com.jfinal.render.RenderFactory; //导入依赖的package包/类
@Override
public void render() {
RenderFactory.me().getRender(view).setContext(request, response).render();
}