service:
public String getTemplateHTML(Bean bean) throws Exception {
if (weather == null) {
return "";
}
Map<String, Object> root = new HashMap<String, Object>();
root.put("bean",bean);
return FreemarkerUtils.getText("*********.ftl", root);
}
action:
request.setAttribute("**********", getTemplateHTML);
jsp:
${requestScope.*********}
本文介绍了一个使用Freemarker模板引擎处理数据并将其传递到JSP页面的例子。具体包括一个公共服务方法getTemplateHTML,该方法接受一个Bean对象作为参数,并通过Freemarker将此Bean的数据转换为HTML字符串。

被折叠的 条评论
为什么被折叠?



