Part photo1= request.getPart("photo");
String photo= photo1.getSubmittedFileName();
getSubmittedFileName();报错:
The method getSubmittedFileName() is undefined for the type Part
Part photo1= request.getPart("photo");
String photo= photo1.getSubmittedFileName();
getSubmittedFileName();报错:
The method getSubmittedFileName() is undefined for the type Part
在tomcat7 的环境下就没有part.getSubmittedFileName()这一方法,无法直接获取文件名。
String cd = part.getHeader("Content-Disposition");
//截取不同类型的文件需要自行判断
String filename = cd.substring(cd.lastIndexOf("=")+2, cd.length()-1);