2012-04-06 102 views
0

我得到一個異常時,我對我的網絡服務器JSP文件,它說以下內容:JSP進口類實現不resloving型

type Exception report 

    message 

    description The server encountered an internal error() that prevented it from fulfilling this request. 

    exception 

    org.apache.jasper.JasperException: Unable to compile class for JSP: 

    An error occurred at line: 6 in the generated java file 
    Only a type can be imported. edu.byu.isys413.data.Customer resolves to a package 

    An error occurred at line: 124 in the jsp file: /account.jsp 
    Customer cannot be resolved to a type 
    121:           <tr valign=top> 
    122:            <td height=19></td> 
    123:            <% if (session.getAttribute("customer") != null) { 
    124:              Customer c = (Customer) session.getAttribute("customer");%> 
    125:            <td align="center"><%="Welcome " +  c.getFirstName() + "!"%></td> 
    126:            <% }%> 
    127:            <td height=19></td> 


    An error occurred at line: 124 in the jsp file: /account.jsp 
    Customer cannot be resolved to a type 
    121:           <tr valign=top> 
    122:            <td height=19></td> 
    123:            <% if (session.getAttribute("customer") != null) { 
    124:              Customer c = (Customer) session.getAttribute("customer");%> 
    125:            <td align="center"><%="Welcome " + c.getFirstName() + "!"%></td> 
    126:            <% }%> 
    127:            <td height=19></td> 


    Stacktrace: 
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92) 
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) 
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439) 
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356) 
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334) 
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321) 
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592) 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) 
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 

,而JSP頁面的樣子

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01    Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
     <%@ page import="edu.Customer" %> 
<% if (session.getAttribute("customer") != null) { 
               Customer c = (Customer) session.getAttribute("customer");%> 
<td align="center"><%="Welcome " + c.getFirstName() + "!"%></td> 
             <% }%> 

我知道很多人在這裏發佈了同樣的問題,但我肯定肯定Customer.java在/WEB-INF/classes/edu/Customer.java下。那麼這裏還有其他配置問題嗎?我使用連接到tomcat的IIS。我可以到文件好,但我不能編譯JSP。 預先感謝您。

回答

0

我當然確定Customer.java在/WEB-INF/classes/edu/Customer.java下。

您需要編譯後的類文件,而不是原始Java源文件。所以,你必須有一個/WEB-INF/classes/edu/Customer.class

您可以使用javac將Java源文件編譯爲類文件。或者考慮使用IDE,如Eclipse,IntelliJ或Netbeans,如果您已經很好地掌握了手動構建/編譯Java項目以及對「classpath」現象的充分理解。然後,IDE將爲您自動完成此操作。

+0

謝謝你的評論。我試圖在cmd中運行javac命令,並且它給了我javac甚至在我設置了javac.exe路徑後仍然無法識別。你碰巧知道問題在哪裏? – TitanTheYaphet 2012-04-06 03:35:53

相關問題