有的时候需要多图上传,并且需要有顺序的上传并有顺序的返回。
我传递的时候是有序的,但是使用getFiles()拿数据的时候就变成了无序的,调试模式跟进发现
public MultipartRequest(HttpServletRequest request, String saveDirectory, int maxPostSize, String encoding, FileRenamePolicy policy)
方法中
Part part;
while ((part = parser.readNextPart()) != null) {
String name = part.getName();
if (name == null) {
throw new IOException(
"Malformed input: parameter name missing (known Opera 7 bug)");
}
if (part.isParam()) {
// It's a parameter part, add it to the vector of values
ParamPart paramPart = (ParamPart) part;
String value = paramPart.getStringValue();
Vector existingValues = (Vector)parameters.get(name);
if (existingValues == null) {
existingValues = new Vector();
parameters.put(name, existingValues);
}
existingValues.addElement(value);
}
else if (part.isFile()) {
// It's a file part
FilePart filePart = (FilePart) part;
String fileName = filePart.getFileName();
if (fileName != null) {
filePart.setRenamePolicy(policy); // null policy is OK
// The part actually contained a file
filePart.writeTo(dir);
files.put(name, new UploadedFile(dir.toString(),
filePart.getFileName(),
fileName,
filePart.getContentType()));
}
else {
// The field did not contain a file
files.put(name, new UploadedFile(null, null, null, null));
}
}
}判断完是否是文件put files中 files是Hashtable 无序的
怎么解决这个无序的问题?令我图片上传是有序的上传后拿到图片也是有序的?
项目:JFinal