我想导入DiskFileItemFactory
类。但是在将库 commons-fileupload.jar
、 commons-io.jar
(源 zip 文件)添加到项目后,我收到此错误:
import org.apache.commons.fileupload.*;
//Error: package org.apache.commons.fileupload does not exists
我将它们导入到 Beans 组件文件中。 服务器:NetBeans 上的 GlassFish。
最佳答案
编译时类路径中不存在提到的包/类。基本上,当您说导入这个或那个时,Java 不知道您在说什么。它在类路径中找不到它们。
将 jar 文件放入项目的 /WEB-INF/lib 文件夹中,此错误应该会消失。
您可以从这里下载 jar commons-io和 commons-fileupload
您可以尝试以下步骤:
1.Right-click the project name (in the "Projects" window) -> New -> Folder, call it (say) "lib". Now open your file browser, navigate to that folder and drop all the custom libraries that you have.
2.Right-click the project -> Properties -> Libraries -> Compile (tab) -> Add JAR/Folder and add the jar files.
关于java - 文件上传包不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26277850/