1. 模板文件static.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8&
1.static.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8&qu
1.FreeMarker需要添加的Maven依赖: <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.23</version> </dependency> 2.使用模板生成HTML代码 2.1 数据模型 public class User { private String
设置example.html为模板文件,然后按照此模板文件生成article-1.html~article-5.html,以此来做简单的演示,代码如下: <?php//将数据存入二维数组$con=array(array('文章标题1','文章内容1'),array('文章标题2','文章内容2'),array('文章标题3','文章内容3'),array('文章标题4','文章内容4'),array('文章标题5','文章内容5'));foreach($con as $id=>$val){ /
读取模板的时候有一个编码: Template template = this.tempConfiguration.getTemplate(templatePath,"UTF-8"); 生成文件的时候使用编码: Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFile), "UTF-8")); 附(freeMarker生成静态文件的代码): public c