com.jfinal.render.RenderException Java Examples
The following examples show how to use
com.jfinal.render.RenderException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonErrorRender.java From jboot-admin with Apache License 2.0 | 6 votes |
@Override public void render() { response.setStatus(getErrorCode()); PrintWriter writer = null; try { response.setContentType(""); writer = response.getWriter(); writer.write(""); writer.flush(); } catch (IOException e) { throw new RenderException(e); } finally { if (writer != null) { writer.close(); } } }
Example #2
Source File: JbootErrorRender.java From jboot with Apache License 2.0 | 6 votes |
@Override public void render() { response.setStatus(getErrorCode()); //render with view String view = getView(); if (view != null) { RenderManager.me().getRenderFactory() .getRender(view) .setContext(request, response) .render(); return; } try { response.setContentType(contentType); PrintWriter writer = response.getWriter(); writer.write(getErrorHtml()); } catch (IOException e) { throw new RenderException(e); } }
Example #3
Source File: JbootResponseEntityRender.java From jboot with Apache License 2.0 | 6 votes |
@Override public void render() { PrintWriter writer = null; try { //默认输出 json,但是 responseEntity 可以配置 Header 覆盖这个输出 response.setHeader("Cache-Control", "no-cache"); response.setHeader("Content-Type", "application/json; charset=utf-8"); response.setStatus(responseEntity.getHttpStatus().value()); Map<String, String> headers = responseEntity.getHeaders(); if (headers != null && !headers.isEmpty()) { for (Map.Entry<String, String> entry : headers.entrySet()) { response.setHeader(entry.getKey(), entry.getValue()); } } String jsonText = responseEntity.getBody() == null ? "" : JsonKit.toJson(responseEntity.getBody()); writer = response.getWriter(); writer.write(jsonText); // writer.flush(); } catch (IOException e) { throw new RenderException(e); } }
Example #4
Source File: BlogFrontendFreeMarkerRender.java From zrlog with Apache License 2.0 | 6 votes |
@SuppressWarnings({"unchecked", "rawtypes"}) public void render() { response.setContentType(getContentType()); Map data = new HashMap(); for (Enumeration<String> attrs = request.getAttributeNames(); attrs.hasMoreElements();) { String attrName = attrs.nextElement(); data.put(attrName, request.getAttribute(attrName)); } PrintWriter writer = null; try { Template template = config.getTemplate(view); writer = response.getWriter(); template.process(data, writer); // Merge the data-model and the template } catch (Exception e) { throw new RenderException(e); } }
Example #5
Source File: RenderHelpler.java From jboot with Apache License 2.0 | 5 votes |
public static void renderHtml(HttpServletResponse response, String html, String contentType) { response.setContentType(contentType); try { PrintWriter responseWriter = response.getWriter(); responseWriter.write(html); } catch (Exception e) { throw new RenderException(e); } }