导入org.apache.commons无法在eclipse juno中解决 [英] The import org.apache.commons cannot be resolved in eclipse juno
问题描述
请任何人告诉我这个错误告诉我什么。以及如何解决它。
提到的包/类不存在于compiletime类路径中。基本上,Java不知道你在说什么,当你说要导入这个。它不能在类路径中找到它们。
它是 Apache Commons FileUpload 。只需下载JAR并将其放在webapp项目的 / WEB-INF / lib
文件夹中,此错误就会消失。不要忘记为 Apache Commons IO 执行相同操作,那就是FileUpload所依赖的地方,否则你将在运行时遇到相同的问题。
与具体问题无关,我看到你使用Tomcat 7,它是一个Servlet 3.0兼容容器。你知道你可以使用新的 request.getPart()
方法获取上传的文件,而不需要整个Commons FileUpload的东西?只需将 @MultipartConfig
注释添加到servlet类,以便您可以使用它。另请参见如何使用JSP将文件上传到服务器/ Servlet?
I having the problem while compiling the my project in eclipse. It was shoving the error The import org.apache.commons cannot be resolved.
Please anyone tell me what does this error tells. and how to solve it.
The mentioned package/classes are not present in the compiletime classpath. Basically, Java has no idea what you're talking about when you say to import this and that. It can't find them in the classpath.
It's part of Apache Commons FileUpload. Just download the JAR and drop it in /WEB-INF/lib
folder of the webapp project and this error should disappear. Don't forget to do the same for Apache Commons IO, that's where FileUpload depends on, otherwise you will get the same problem during runtime.
Unrelated to the concrete problem, I see that you're using Tomcat 7, which is a Servlet 3.0 compatible container. Do you know that you can just use the new request.getPart()
method to obtain the uploaded file without the need for the whole Commons FileUpload stuff? Just add @MultipartConfig
annotation to the servlet class so that you can use it. See also How to upload files to server using JSP/Servlet?
这篇关于导入org.apache.commons无法在eclipse juno中解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!