只能导入一个类型。 com.journaldev.model.Employee 解析为一个包

Only a type can be imported. com.journaldev.model.Employee resolves to a package

index22.jsp

<%@ page import="java.util.List" %>
  <%@ page import="com.journaldev.model.Employee" %>
<%@ page import="com.journaldev.model.Person" %>
<%@ page import="com.journaldev.model.Address" %>

当我在浏览器上访问 index22.jsp 时出现以下错误:

Jul 12, 2015 8:53:37 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/JSTL] threw exception [Unable to compile class for JSP: 

An error occurred at line: [15] in the generated java file: [C:\Users\piyush\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\JSTL\org\apache\jsp\index22_jsp.java]
Only a type can be imported. com.journaldev.model.Employee resolves to a package

An error occurred at line: [16] in the generated java file: [C:\Users\piyush\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\JSTL\org\apache\jsp\index22_jsp.java]
Only a type can be imported. com.journaldev.model.Person resolves to a package

An error occurred at line: [17] in the generated java file: [C:\Users\piyush\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\JSTL\org\apache\jsp\index22_jsp.java]
Only a type can be imported. com.journaldev.model.Address resolves to a package

Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: [15] in the generated java file: [C:\Users\piyush\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\JSTL\org\apache\jsp\index22_jsp.java]
Only a type can be imported. com.journaldev.model.Employee resolves to a package

An error occurred at line: [16] in the generated java file: [C:\Users\piyush\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\JSTL\org\apache\jsp\index22_jsp.java]
Only a type can be imported. com.journaldev.model.Person resolves to a package

An error occurred at line: [17] in the generated java file: [C:\Users\piyush\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\JSTL\org\apache\jsp\index22_jsp.java]
Only a type can be imported. com.journaldev.model.Address resolves to a package

Stacktrace:
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:485)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:379)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

我还包含了一些 JSTL jar 并使用了 Tomcat7v

javax.servlet.jsp.jstl-1.2.1.jar
taglibs-standard-compat-1.2.5.jar
taglibs-standard-impl-1.2.5.jar
taglibs-standard-jstlel-1.2.5.jar
taglibs-standard-spec-1.2.5.jar

我想得到这个错误是因为我包含但未确认的 JSTL。 知道我遇到的错误吗?

Employee.java

package com.journaldev.model;

public class Employee implements Person {

    private String name;
    private int id;
    private Address address;

    public Employee() {
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName(String nm) {
        this.name = nm;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    @Override
    public String toString(){
        return "ID="+id+",Name="+name+",Address="+address;
    }

}

错误是因为项目上有感叹号。我创建了新的 Web 动态项目并且 运行 顺利。