当前位置:网站首页>freemarker的使用
freemarker的使用
2022-07-02 10:56:00 【爱窦】
依赖
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
模板内容
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:gw=\"urn:gwService\">
<SOAP-ENV:Body SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">
<gw:ldtpExchStatusQuery>
<transId>${transId}</transId>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
具体使用
//设置数据
Map dataMap = new HashMap<>();
dataMap.put("transId","abc");
//设置版本号
Version version = new Version("2.3.28");
Configuration configuration = new Configuration(version);
configuration.setDefaultEncoding("utf-8");
//模板文件路径
configuration.setDirectoryForTemplateLoading(new File("D:\freemarker.xml"));
Template template = configuration.getTemplate("freemarker.xml");
ByteArrayOutputStream out = new ByteArrayOutputStream();
Writer w = new OutputStreamWriter(out, "utf-8");
//将数据写入模板
template.process(dataMap, w);
w.close();
byte[] bytes = out.toByteArray();
out.close();
MultipartFile file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), bytes);//得到最终模板
边栏推荐
- Dangbei projection 4K laser projection X3 Pro received unanimous praise: 10000 yuan projector preferred
- The 29 year old programmer in Shanghai was sentenced to 10 months for "deleting the database and running away" on the day of his resignation!
- The conference on the growth of all things was held in Hangzhou, and dangbei was selected into the top 100 list of future unicorns in China in 2022
- 693. 行程排序(map + 拓扑)
- [development environment] 010 editor tool (tool download | binary file analysis template template installation | shortcut key viewing and setting)
- [deep learning] simple implementation of neural network forward propagation
- Golang quickly generates model and queryset of database tables
- Penetrate the remote connection database through the Intranet
- 抓包工具fiddler学习
- How to set QT manual layout
猜你喜欢

Launcher启动过程

Federated Search: all requirements in search

(POJ - 1984) navigation nightare (weighted and search set)
![[development environment] 010 editor tool (tool download | binary file analysis template template installation | shortcut key viewing and setting)](/img/de/7d70f513577e93f1bde1969935a29e.jpg)
[development environment] 010 editor tool (tool download | binary file analysis template template installation | shortcut key viewing and setting)

Integral link, inertia link and proportion link in Simulink

Analysis of CPU surge in production environment service

Origin绘制热重TG和微分热重DTG曲线
![[Hongke technology sharing] how to test DNS server: DNS performance and response time test](/img/f4/d8c21d6c33985fd6d819cd44c22c72.png)
[Hongke technology sharing] how to test DNS server: DNS performance and response time test

错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”

Systemserver process
随机推荐
联合搜索:搜索中的所有需求
Selenium installing selenium in pycharm
The conference on the growth of all things was held in Hangzhou, and dangbei was selected into the top 100 list of future unicorns in China in 2022
线性dp求解 最长子序列 —— 小题三则
Chaos engineering platform chaosblade box new heavy release
抓包工具fiddler学习
你知道Oracle的数据文件大小有上限么?
P3008 [USACO11JAN]Roads and Planes G (SPFA + SLF优化)
QT - make a simple calculator - realize four operations
The 29 year old programmer in Shanghai was sentenced to 10 months for "deleting the database and running away" on the day of his resignation!
Dangbei projection 4K laser projection X3 Pro received unanimous praise: 10000 yuan projector preferred
Pycharm连接远程服务器
Design of non main lamp: how to make intelligent lighting more "intelligent"?
Code implementation MNLM
Use of UIC in QT
Systemserver process
qt中uic的使用
rxjs Observable 自定义 Operator 的开发技巧
Essential elements of science fiction 3D scenes - City
Qt新项目_MyNotepad++