当前位置:网站首页>Use of freemaker
Use of freemaker
2022-07-02 14:16:00 【Love sinus】
rely on
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
Template content
<?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>
Specific use
// Set up the data
Map dataMap = new HashMap<>();
dataMap.put("transId","abc");
// Set version number
Version version = new Version("2.3.28");
Configuration configuration = new Configuration(version);
configuration.setDefaultEncoding("utf-8");
// Template file path
configuration.setDirectoryForTemplateLoading(new File("D:\freemarker.xml"));
Template template = configuration.getTemplate("freemarker.xml");
ByteArrayOutputStream out = new ByteArrayOutputStream();
Writer w = new OutputStreamWriter(out, "utf-8");
// Write data to the template
template.process(dataMap, w);
w.close();
byte[] bytes = out.toByteArray();
out.close();
MultipartFile file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), bytes);// Get the final template
边栏推荐
- 混沌工程平台 ChaosBlade-Box 新版重磅发布
- mysql ---- Oracle中的rownum转换成MySQL
- Dingtalk 发送消息
- C crystal report printing
- Using computed in uni app solves the abnormal display of data () value in tab switching
- 关于Flink框架窗口(window)函数最全解析
- MySQL -- convert rownum in Oracle to MySQL
- HMS core machine learning service helps zaful users to shop conveniently
- rxjs Observable 自定义 Operator 的开发技巧
- uni-app中使用computed解决了tab切换中data()值显示的异常
猜你喜欢
Use bloc to build a page instance of shutter
Use of UIC in QT
Origin plots thermogravimetric TG and differential thermogravimetric DTG curves
[Hongke technology sharing] how to test DNS server: DNS performance and response time test
QT new project_ MyNotepad++
Use of swagger
Error: eacces: permission denied, access to "/usr/lib/node_modules"
The global special paper revenue in 2021 was about $27 million, and it is expected to reach $35 million in 2028. From 2022 to 2028, the CAGR was 3.8%
c# 水晶报表打印
In 2021, the global revenue of structural bolts was about $796.4 million, and it is expected to reach $1097.6 million in 2028
随机推荐
Téléchargement par navigateur
MySQL 45 lecture - learning from the actual battle of geek time MySQL 45 Lecture Notes - 04 | easy to understand index (Part 1)
Selenium installing selenium in pycharm
Origin绘制热重TG和微分热重DTG曲线
[Hongke technology sharing] how to test DNS server: DNS performance and response time test
Error: eacces: permission denied, access to "/usr/lib/node_modules"
Chaos engineering platform chaosblade box new heavy release
Subcontracting configuration of uniapp applet subpackages
如何设置Qt手工布局
Analysis of CPU surge in production environment service
YOLOv3&YOLOv5输出结果说明
默认插槽,具名插槽,作用域插槽
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
SystemServer进程
瀏覽器驅動的下載
快解析:轻松实现共享上网
TeamTalk源码分析之win-client
使用BLoC 构建 Flutter的页面实例
How kaggle uses utility script
Getting started with QT - making a simple calculator