`
Beaver's
  • 浏览: 396071 次
  • 性别: Icon_minigender_2
  • 来自: 天津
社区版块
存档分类
最新评论

fileItems=upload.parseRequest(request); 空指针错误

    博客分类:
  • web
 
阅读更多
servlet 实现文件上传的时候,出现 fileItems=upload.parseRequest(request); 空指针错误,

解决方案是在form 标签中添加属性 enctype="multipart/form-data" ,是设置表单的MIME编码。默认情况,这个编码格式是application/x-www-form-urlencoded,不能用于文件上传;只有使用了multipart/form-data,才能完整的传递文件数据,进行下面的操作.

另外设置 method="post"
分享到:
评论
1 楼 piaoxue_x 2011-12-23  
貌似,不是这个原因,我试了试不行啊,哥们。。。。

相关推荐

    jspsmartupload

    List fileItems = upload.parseRequest(request); //开始读取上传信息 Iterator iter = fileItems.iterator(); // 依次处理每个上传的文件 while(iter.hasNext()) { FileItem item = (FileItem) iter.next(); // ...

    flex中的文件上传(简单例子)

    List fileItems = upload.parseRequest(request); Iterator iter = fileItems.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (!item.isFormField()) { ...

    java实现导入文件

    fileItems = upload.parseRequest(req); } catch (FileUploadException e1) { e1.printStackTrace(); } Iterator<FileItem> iter = fileItems.iterator(); String regExp = ".+\\\\(.+)$"; Pattern p = ...

    java中图片上传并在jsp页面显示.txt

    List fileItems = upload.parseRequest(request); Iterator i = fileItems.iterator(); String name = ((FileItem) i.next()).getString(); // 获取表单中的文本输入 FileItem fi = (FileItem) i.next(); // ...

    upload,upload

    - 上述代码首先通过`request.getParameter("method")`获取请求中的`method`参数,判断是否为"upload",如果是,则执行文件上传逻辑。 ### 2. 文件名处理与保存路径设置 #### 核心概念 - **文件名处理**: 为了避免...

    java文件上传下载.docx

    List<FileItem> fileItems = fu.parseRequest(request); Iterator<FileItem> i = fileItems.iterator(); // 依次处理每一个文件: while (i.hasNext()) { FileItem fi = (FileItem) i.next(); // 获得文件名,...

    commons-fileupload-1.2.jar和commons-io-1.3.2.jar

    List fileItems = upload.parseRequest(req); // assume we know there are two files. The first file is a small // text file, the second is unknown and is written to a file on // the server Iterator ...

    实现异地上传

    List fileItems = fu.parseRequest(request); // 获取客户端IP地址 String remoteAddr = request.getRemoteAddr(); // 获取服务器名称 String serverName = request.getServerName(); // 获取服务器的实际...

    java 文件上传下载

    List<FileItem> fileItems = fu.parseRequest(request); Iterator<FileItem> i = fileItems.iterator(); while (i.hasNext()) { FileItem fi = (FileItem) i.next(); String fileName = fi.getName(); // ...

    Common-fileupload组件实现文件上传.pdf

    List<FileItem> fileItems = fu.parseRequest(request); Iterator<FileItem> i = fileItems.iterator(); // 依次处理每一个文件: while (i.hasNext()) { FileItem fi = i.next(); // 获得文件名,这个文件名...

    java文件上传下载实例

    List<FileItem> fileItems = fu.parseRequest(request); Iterator<FileItem> i = fileItems.iterator(); // 依次处理每一个文件: while (i.hasNext()) { FileItem fi = i.next(); // 获得文件名,这个文件名...

    Java实现上传和下载有关教程

    List fileItems = diskFUpload.parseRequest(request); Iterator it = fileItems.iterator(); while (it.hasNext()) { FileItem fi = (FileItem) it.next(); String filePathName = fi.getName(); // 获取...

    用java在web环境下上传和下载文件的技巧

    List<FileItem> fileItems = fu.parseRequest(request); for (FileItem fi : fileItems) { String fileName = fi.getName(); // 处理文件逻辑... fi.write(new File(uploadPath + "/" + fileName)); } } ...

    java上传文件(upload)

    httpUpload.parseRequest(); } catch (IOException e) { // 处理异常 } // 获取上传文件列表 List<HttpUpload.FileItem> fileItems = httpUpload.getFileItems(); } ``` 3. **处理上传文件**:遍历`...

    upfileload

    List<FileItem> fileItems = upload.parseRequest(req); // 处理每个上传的文件 for (FileItem item : fileItems) { if (!item.isFormField()) { // 获取文件名 String fileName = item.getName(); // 检查...

    java文件上传与下载

    List<FileItem> fileItems = fu.parseRequest(request); Iterator<FileItem> i = fileItems.iterator(); // 遍历每一个文件项 while (i.hasNext()) { FileItem fi = (FileItem) i.next(); if (!fi....

    上传文件原代码

    List fileItems = fu.parseRequest(request); Iterator iter = fileItems.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (!item.isFormField()) { String name = item....

    上传文件所用jar包.rar

    List<FileItem> items = upload.parseRequest(request); ``` 4. **处理FileItems**:遍历`items`列表,对于每个`FileItem`,如果是普通表单字段则读取其值,如果是文件则保存到服务器。 ```java for (FileItem ...

    getContentServlet_java(richText).txt

    List<FileItem> fileItems = fu.parseRequest(request); Iterator<FileItem> iter = fileItems.iterator(); FileItem item = (FileItem) iter.next(); if (!item.isFormField()) { String name = item.getName...

    commons-fileupload上传实现

    List<FileItem> items = upload.parseRequest(request); for (FileItem item : items) { if (item.isFormField()) { // 处理普通文本字段 } else { // 处理上传的文件 String fileName = item.getName(); //...

Global site tag (gtag.js) - Google Analytics