关于freemarker生成相对路径的问题
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import freemarker.template.*;
public class free {
private final Log logger = LogFactory.getLog(getClass());
private Configuration freemarker_cfg = null;
public static void main(String[] args)
{
//@todo 自己的一个类
FromForm aItem = null;
//@todo 装入新闻
//NewsItem = loadNewsItem(1);
free test = new free();
Map root = new HashMap();
root.put( "newsitem ", aItem);
String sGeneFilePath = "/tpxw/ ";
String sFileName = "1.htm ";
boolean bOK = test.geneHtmlFile( "/tpxw/view.html ",root, sGeneFilePath,sFileName);
}
/**
* 获取freemarker的配置. freemarker本身支持classpath,目录和从ServletContext获取.
*/
protected Configuration getFreeMarkerCFG()
{
if (null == freemarker_cfg)
{
// Initialize the FreeMarker configuration;
// - Create a configuration instance
freemarker_cfg = new Configuration();
// - FreeMarker支持多种模板装载方式,可以查看API文档,都很简单:路径,根据Servlet上下文,classpath等等
&