当前位置:网站首页>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);//得到最终模板
边栏推荐
- 当贝投影4K激光投影X3 Pro获得一致好评:万元投影仪首选
- [Hongke technology sharing] how to test DNS server: DNS performance and response time test
- Use bloc to build a page instance of shutter
- Pointer from entry to advanced (1)
- Golang quickly generates model and queryset of database tables
- On flow delivery between microservices
- Using computed in uni app solves the abnormal display of data () value in tab switching
- In 2021, the global styrene butadiene styrene (SBS) revenue was about $3722.7 million, and it is expected to reach $5679.6 million in 2028
- Drawing Nyquist diagram with MATLAB
- Runhe hi3516 development board openharmony small system and standard system burning
猜你喜欢

Essential elements of science fiction 3D scenes - City

SystemServer进程

QT - make a simple calculator - realize four operations

抓包工具fiddler学习

selenium 在pycharm中安装selenium

How to explain binary search to my sister? This is really difficult, fan!

你知道Oracle的数据文件大小有上限么?

Use of UIC in QT
【文档树、设置】字体变小

selenium,元素操作以及浏览器操作方法
随机推荐
Qt如何设置固定大小
Halcon extract orange (Orange)
ensp简单入门
默认插槽,具名插槽,作用域插槽
大家信夫一站式信用平台让信用场景“用起来
[Blue Bridge Cup] children's worship circle
QT - make a simple calculator - realize four operations
Simple introduction to ENSP
你知道Oracle的数据文件大小有上限么?
Which do you choose between Alibaba P7 with an annual salary of 900000 and deputy department level cadres?
ArrayList and LinkedList
P1347 排序(拓扑 + spfa判断环 or 拓扑[内判断环])
Use bloc to build a page instance of shutter
Use of UIC in QT
代码实现MNLM
Systemserver process
Selenium element positioning method
Characteristics of selenium
腾讯云 TStor 统一存储通过信通院首批文件存储基础能力评测
Integral link, inertia link and proportion link in Simulink