我是靠谱客的博主 彪壮烧鹅,这篇文章主要介绍 struts中应用MultipartRequest,现在分享给大家,希望可以做个参考。

//struts中的action对应的actionform一定要随便写一个不存在的actionform,否则,进入action之后, struts可能对request作了什么操作,使得无法应用MultipartRequest

 String filePath = request.getRealPath("/") + "docfile";// 上传到指定的docfile包中
  filePath = filePath.replace(".//", "//");
  File testFolder = new File(filePath);
  if (!testFolder.exists()) {
   try {
    testFolder.mkdir();

   } catch (Exception e) {
    throw new Exception("无法创建附件存放文件夹");
   }
  }

share.tools.servlet.MultipartRequest mr=new share.tools.servlet.MultipartRequest(request, testFolder.getAbsolutePath(), Integer.MAX_VALUE,
                "gbk", new DefaultFileRenamePolicy());//执行这个之后就会上传文件了

 filedvalues[i]= mr.getParameter(filednames[i]);//获取字段值

multipartrequest 下载地址http://www.servlets.com/cos/index.html

最后

以上就是彪壮烧鹅最近收集整理的关于 struts中应用MultipartRequest的全部内容,更多相关内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(132)

评论列表共有 0 条评论

立即
投稿
返回
顶部