freemarker 替换字符串,模板,可以用来动态生成代码
发布日期:2021-06-30 20:07:31
浏览次数:2
分类:技术文章
本文共 765 字,大约阅读时间需要 2 分钟。
freemarker 通过字符串模板生成,会把map中 name 对应的变量替换字符串模板中的${name}
package com.thinkgem.jeesite.test.test;import java.io.IOException;import java.io.StringReader;import java.io.StringWriter;import java.util.HashMap;import java.util.Map;import freemarker.template.Configuration;import freemarker.template.Template;import freemarker.template.TemplateException;public class aaa { public static void main(String[] args) throws TemplateException, IOException { Mapmap=new HashMap (); map.put("username", "lisi"); String templateString="${username}/zhangsan"; StringWriter result = new StringWriter(); Template t = new Template("name1", new StringReader(templateString), new Configuration()); t.process(map, result); System.out.println(result.toString()); } }
转载地址:https://liuhuiyao.blog.csdn.net/article/details/52701974 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关注你微信了!
[***.104.42.241]2024年04月29日 08时24分11秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
调试 LenaCV 3D Camera (Linux)
2021-07-03
OpenCV杂记 - Mat in C++
2021-07-03
lnmp部署
2021-07-03
location区段
2021-07-03
nginx访问控制、基于用户认证、https配置
2021-07-03
用zabbix监控nginx
2021-07-03
SaltStack
2021-07-03
Jenkins 控制台输出中的奇怪字符
2021-07-03
Linux添加系统调用
2021-07-03
linux内存的寻址方式
2021-07-03
ubunut16.04的pip3出现问题,重新安装pip3
2021-07-03
how2heap-double free
2021-07-03
how2heap-fastbin_dup_consolidate
2021-07-03
orw_shellcode_模板
2021-07-03
[fmt+shellcode]string
2021-07-03
fmt在bss段(neepusec_easy_format)
2021-07-03
[double free] 9447 CTF : Search Engine
2021-07-03
python 函数式编程
2021-07-03
python编码
2021-07-03