使用freemarker对模板进行渲染

技术杂谈82

public class FreemarkerUtilsTest extends TestCase {
public void generateStringTest(){
Map<string,object> map= </string,object> new HashMap<>();
map.put( "date" , "2017-05-11 11:55:55" );
map.put( "caseNo" , "AJ00000001" );
map.put( "descrip" , "&#x8FD9;&#x662F;&#x63CF;&#x8FF0;&#x4FE1;&#x606F;==========" );
String template= "&#x6848;&#x4EF6;&#x7F16;&#x53F7;&#x4E3A;&#xFF1A;${caseNo!}&#xA0;&#xA0; "
+ " &#x65E5;&#x671F;&#x4E3A;&#xFF1A;${date!} "
+ " &#x81EA;&#x52A8;&#x83B7;&#x53D6;&#x65E5;&#x671F;&#x4E3A;&#xFF1A;${ .now?string('yyyy&#x5E74;MM&#x6708;dd&#x65E5;')}"
+ "&#x63CF;&#x8FF0;&#xFF1A;${descrip!}" ;
String generateString = FreemarkerUtils.generateString(map, template);
System.out.println( "------" );
System.out.println(generateString);
}

Original: https://www.cnblogs.com/toSeeMyDream/p/12381243.html
Author: nickTimer
Title: 使用freemarker对模板进行渲染