开发者社区> 问答> 正文

getSubmittedFileName();报错 ?报错

Part photo1= request.getPart("photo");
String photo= photo1.getSubmittedFileName();

getSubmittedFileName();报错:
    The method getSubmittedFileName() is undefined for the type Part

展开
收起
爱吃鱼的程序员 2020-06-23 20:32:47 1292 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    在tomcat7的环境下就没有part.getSubmittedFileName()这一方法,无法直接获取文件名。
    Stringcd=part.getHeader("Content-Disposition");
    //截取不同类型的文件需要自行判断
    Stringfilename=cd.substring(cd.lastIndexOf("=")+2,cd.length()-1);

    2020-06-23 20:33:03
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载