当前位置: 代码迷 >> HTML/CSS >> FreeMarker 生成静态html(举例来说)
  详细解决方案

FreeMarker 生成静态html(举例来说)

热度:1411   发布时间:2012-09-16 17:33:17.0
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>
 
?

?

  相关解决方案