Spring mvc 如何将带有多个文件的POST请求从Robot框架发送到Spring引导控制器
我试图从Robot框架中编写的关键字调用Spring Boot标准控制器。 我想上传多个XML文件 这是我的控制器:Spring mvc 如何将带有多个文件的POST请求从Robot框架发送到Spring引导控制器,spring-mvc,spring-boot,file-upload,http-post,robotframework,Spring Mvc,Spring Boot,File Upload,Http Post,Robotframework,我试图从Robot框架中编写的关键字调用Spring Boot标准控制器。 我想上传多个XML文件 这是我的控制器: @PostMapping(value = "/myUrl", produces = "application/xml") public ResponseEntity<String> getXmlResponse(@RequestParam("files") MultipartFile[] files) throws Exception { logger.de
@PostMapping(value = "/myUrl", produces = "application/xml")
public ResponseEntity<String> getXmlResponse(@RequestParam("files") MultipartFile[] files) throws Exception {
logger.debug("getXmlResponse :: files.size = " + files.length);
List<String> bundles = Arrays.stream(files).map(f -> {
try {
return new String(f.getBytes(), UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList());
String xmlBundle = xmlProviderService.generateXmlBundle(bundles.stream().toArray(String[]::new));
[...]
return response;
}
调用控制器时,我的文件
数组始终为空
getXmlResponse::files.size=0
知道我做错了什么吗?是的,我看到了这个链接并尝试了,但同样的问题也发生了。我的多部分文件[]仍然为空。您如何配置文件上载请求可能存在问题。您的意思是我的Spring控制器可能有问题?知道会是什么吗?
Get Xml Response
Create Session template-provider http://localhost:8081
&{headers} Create Dictionary Content-Type=multipart/form-data
${fileData1} = Get Binary File ${CURDIR}${/}E1.xml
${fileData2} = Get Binary File ${CURDIR}${/}E2.xml
&{files} = Create Dictionary
Set To Dictionary ${files} file1=${fileData1}
Set To Dictionary ${files} file2=${fileData2}
${resp} = Post Request template-provider /myUrl headers=${headers} files=${files}
Should Be Equal As Strings ${resp.status_code} 200
Log ${resp.text}