0
index22.jsp只能導入一個類型。 com.journaldev.model.Employee解析爲一個包
<%@ 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罐和使用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;
}
}
你能張貼'com.journaldev.model.Employee'完整的代碼?它也是一個包或類? –
@Amit包含Employee.java –
你的課程看起來不錯。確保Employee.class部署在目錄** com/journaldev/model **下,而不是** com/journaldev/model/Employee ** –