首页 > 解决方案 > Eclipse cannot find imports : com.oreilly.servlet.* , org.apache.commons.io.*

问题描述

<%@page contentType="text/html;charset=euc-kr"%>
<%@page import="com.oreilly.servlet.MultipartRequest" %>
<%@page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy"%>
<%@page import="java.util.*,java.io.*"%>
<%
String saveFolder = "C:/Jsp/myapp/WebContent/ch12/filestorage";
String encType = "euc-kr";
int maxSize = 5 * 1024 * 1024;
try {
    MultipartRequest multi = null;
    multi = new MultipartRequest(request, saveFolder, maxSize,
            encType, new DefaultFileRenamePolicy());
    Enumeration params = multi.getParameterNames();

    while (params.hasMoreElements()) {
        String name = (String) params.nextElement();
        String value = multi.getParameter(name);
        out.println(name + " = " + value + "<br/>");
    }

    Enumeration files = multi.getFileNames();
    while (files.hasMoreElements()) {
        String name = (String) files.nextElement();
        String filename = multi.getFilesystemName(name);
        String original = multi.getOriginalFileName(name);
        String type = multi.getContentType(name);
        File f = multi.getFile(name);
        out.println("파라미터 이름 : " + name + "<br/>");
        out.println("실제 파일 이름 : " + original + "<br/>");
        out.println("저장된 파일 이름 : " + filename + "<br/>");
        out.println("파일 타입 : " + type + "<br/>");
        if (f != null) {
            out.println("크기 : " + f.length()+"바이트");
            out.println("<br/>");
        }
    }
} catch (IOException ioe) {
    System.out.println(ioe);
} catch (Exception ex) {
    System.out.println(ex);
}
%>

this is an example code. the problem is very simple. eclipse simply cannot find imports even if the external libraries are stored in WebContent/WEB-INF/lib.

I tried reinstallation, searching on the internet and etc for hours but I still cannot find any solutions for this. I triple,quadra checked import directive. I cannot see any spelling problem

why does this happen to my eclipse?(I am using eclipse oxygen)

标签: javaeclipse

解决方案


下载cos.jar地址:https ://jar-download.com/artifact-search/cos

  • 右键构建路径
  • 配置构建路径,
  • addcos.jar添加外部jar

推荐阅读