FreeMarker 生成静态html(举例)
/* -----------test.java---------- */
package auh.action;
import java.util.HashMap;
import java.util.Map;
import auh.server.MakeFile;
import com.opensymphony.xwork2.ActionSupport;
public class test extends ActionSupport {
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
Map<String,Object> root = new HashMap<String,Object>();
String name="xujianke";
root.put("book", name);
MakeFile make=new MakeFile();
make.geneHtmlFile("book.ftl", root,"/test", "index.html");
System.out.println(make.getSRootDir());
return SUCCESS;
}
}/* ------book.ftl (这个文件放在web根目录下的/WEB-INF/template)----- */
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Hello World</title>
</head>
<body>
${book}<br>哈哈
</body>
</html> 相关推荐
81314797 2020-11-18
89314493 2020-11-03
81941231 2020-09-17
thisisid 2020-09-09
如狼 2020-08-15
82384399 2020-06-16
86384798 2020-05-12
80183053 2020-05-02
86384798 2020-04-26
86384798 2020-04-11
rionchen 2020-04-09
86384798 2020-04-07
86384798 2020-04-04
80183053 2020-03-07
87201943 2020-03-06
83961233 2020-02-26
87201943 2020-02-21