将 xml 格式的请求正文存档到 zip 存档时,文件以 unsi 编码写入,即提取物中非常多的西里尔字母无法正确显示。我试图通过jmeter属性规定默认编码,它没有帮助,我试图通过采样器规定逻辑prev.setDataEncoding(“UTF-8”),文件仍然打包在ansi中,我也试图定义prev.setDataEncoding("UTF-8" in jmeter.bat ),仍然没有帮助,也许有一些选项可以在代码逻辑本身中强制输入 utf8?
def destination = new java.util.zip.ZipOutputStream(new FileOutputStream(new File('request' + ${__Random(100000,200000,)} + '.zip')))
destination.putNextEntry(new java.util.zip.ZipEntry(prev.getSampleLabel() + '.xml'))
destination << prev.getSamplerData().bytes
destination.close()
该文件以 JVM 的默认编码(file.encoding 系统属性的值)编写,可以在system.properties文件中设置
如果您只想为制作 ZIP 存档的代码强制更改编码,这也是可能的:
在ZipOutputStream的构造函数级别
并将请求写入文件时