/WebRoot/huigou/include/head.ftl
/WebRoot/huigou/promotion/index.ftl
上面两个目录结构:
我现在想在index.ftl中<# include "../include/head.ftl">
这样写找不文件,而且也不支持../
大家帮忙看看,谢谢啦!

解决方案 »

  1.   

    // 初始化FreeMarker配置
    // 创建一个Configuration实例
    cfg = new Configuration(); String path = this.getClass().getClassLoader().getResource("")
    .getPath();
    int web_inf = path.indexOf("WEB-INF");
    p = path.substring(0, web_inf); // 设置FreeMarker的模版文件位置
    try {
    cfg.setDirectoryForTemplateLoading(new File(p + "huigou"));
    } catch (Exception e) {
    e.printStackTrace();
    }
    省事的话把两个文件放在同一目录下