多文件上传的 问题 String index out of range: -1在线等!
我做了一个多文件的上传,但是测试的是总是提醒我这样的话String index out of range: -1
不知道是什么意思,希望大家帮帮,代码在这!哪个地方需要改进
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
CompanyintroForm companyintroForm = (CompanyintroForm) form;
FormFile file = companyintroForm.getTheFile();
FormFile file2 = companyintroForm.getTheFile2();
FormFile file3 = companyintroForm.getTheFile3();
Map <String, FormFile> fileMap = new HashMap <String, FormFile> ();
fileMap.put( "file " , file);
fileMap.put( "file2 " , file2);
fileMap.put( "file3 " , file3);
Set fileSet = fileMap.entrySet();
Iterator iter = fileSet.iterator();
// 取当前系统路径E:\Tomcat5\webapps\strutsUpload\ 其中strutsUpload为当前context
String filePath = this.getServlet().getServletContext().getRealPath( "/ ");
// 保存文件的文件夹
File savePath = new File(filePath + "UploadFiles\\ ");
filePath = filePath+ "UploadFiles\\ ";
if (!savePath.exists()) {
savePath.mkdir();
}
while (iter.hasNext()) {
Map.Entry unit = (Map.Entry) iter.next();
String key = (String) unit.getKey();
FormFile file0 = (FormFile) unit.getValue();
//文件大小符合要求,且是图片文件
if ((file.getFileSize() > = 1)&& DealPhoto.isPhoto(file)) {
//图片类别
String photoType = key.substring(key.indexOf( "* ") + 1, key