gpt4 book ai didi

java - 无法迭代 List

转载 作者:太空宇宙 更新时间:2023-11-04 12:59:05 24 4
gpt4 key购买 nike

以下是我从网页上传多个文件的函数。我的文件位于 MultipartFile --> 文件变量列表中。我无法迭代每个文件。然而 log.info("file"+files) 打印了 file[]。这意味着文件返回“[]”。这是什么意思?我哪里出错了?

public String addNodeAndDocNew(TreeType treeType, ObjectId parentNodeId, NodeType nodeType, String displayName, String attrList, List<MultipartFile> files, String userId,
String passwd) {
String result = "";
log.info("file"+ files);
log.info("userId=" + userId);
log.info("passwd=" + passwd);
log.info("nodeType=" + nodeType);
log.info("displayName=" + displayName);
if (attrList != null)
log.info("attributesList=" + attrList.toString());
ObjectId nodeId = null;
for(MultipartFile file : files)
{
log.info("Yess");
if (file.isEmpty()) {
log.info("Nothing attached, just adding node, not the doc");
nodeId = addNode(treeType, parentNodeId, nodeType, displayName, attrList, userId, passwd);
if (nodeId != null)
log.info("Just added node, no doc sent");
}

else {
log.info("file=" + file.getOriginalFilename());
nodeId = addNode(treeType, parentNodeId, nodeType, displayName, attrList, userId, passwd);
if (nodeId != null) {
docService.uploadDoc(nodeId, file, userId, passwd);
log.info("Added node, and doc");
} else {
log.info("addNode() returned null");
}
}

if (nodeId != null) {
log.info("addNodeAndDoc completed for node id : " + nodeId.toString());
result += nodeId.toString()+ "@@";
} else
return null;
}
log.info("Yess1");
return result;
}

最佳答案

However log.info(files) printed File[].

所以,你给定的数组是空的。这就是为什么你不能迭代它! ;)

关于java - 无法迭代 List<MultipartFile>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35082878/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com