TemplatedPortlet.java 文件源码

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

项目:flashlight-search 作者:
/**
 * Renders the given template
 *
 * @param request The request
 * @param response The response
 * @param ctx The template context
 * @param templatePath The path of the template, relative to the templates path given in the init parameters
 *
 * @throws PortletException Thrown if there is an error during template processing
 * @throws IOException Thrown if there is an error while writing the response
 */
public void renderTemplate(RenderRequest request, RenderResponse response, Map<String, Object> ctx, String templatePath) throws PortletException, IOException {
    PortletContext portletCtx = this.getPortletContext();
    String templateResourcePath = String.format(TEMPLATE_PATH_FORMAT, portletCtx.getPortletContextName(), this.templatesPath, templatePath);

    if(this.templateResourceLoader.hasTemplateResource(templateResourcePath)) {
        try {
            this.writeTemplate(request, response, ctx, templateResourcePath);
        } catch(TemplateException e) {
            throw new PortletException(e);
        }
    } else {
        throw new TemplateNotFoundException(templateResourcePath);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号