freemarker嵌入文件输出结果

freemarker嵌入文件输出结果


1、嵌入的文件代码

inc.ftl:

<#assign username="李思思">

2、父文件代码

inner.ftl:

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>freemarker</title>

  </head>
  
  <body>
     <#--freemarker-->
     <#include "/inc/inc.ftl"/>
     ${username}
  </body>
</html>

3、测试方法

@Test
public void testInner()
{
	studentPrint("inner.ftl");
}

4、测试结果

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>freemarker</title>

  </head>
  
  <body>
          李思思
  </body>
</html>


原文地址:https://www.cnblogs.com/hzcya1995/p/13315031.html