TemplatedPortlet.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:flashlight-search 作者:
/**
 * Writes the template's rendering in the portlet response
 *
 * @param request The request
 * @param response The response
 * @param ctx The template context
 * @param templateResourcePath The template to write
 *
 * @throws IOException Thrown if something goes wrong when writing the response
 * @throws TemplateException Thrown if something goes wrong when processing the template
 */
private void writeTemplate(RenderRequest request, RenderResponse response, Map<String, Object> ctx, String templateResourcePath) throws TemplateException, IOException {
    TemplateResource templateResource = this.templateResourceLoader.getTemplateResource(templateResourcePath);
    Template template = this.templateManager.getTemplate(templateResource, false);

    this.templateManager.addTaglibSupport(template, this.portal.getHttpServletRequest(request), this.portal.getHttpServletResponse(response));
    this.enrichTemplateContext(request, response, template);

    Set<Entry<String, Object>> contextObjects = ctx.entrySet();
    for(Entry<String, Object> obj : contextObjects) {
        template.put(obj.getKey(), obj.getValue());
    }

    template.processTemplate(response.getWriter());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号