2011-09-08 14 views
0

我有错误,如一个问题:JSP/Tomcat开发:intellij想法是否自动将包移动到web-inf文件夹?

HTTP Status 500 - 

-------------------------------------------------------------------------------- 

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: 9 in the generated java file 
Only a type can be imported. com.test.util.ConnectionManager resolves to a package 

An error occurred at line: 31 in the jsp file: /test.jsp 
EmployeeDAO cannot be resolved to a type 
28:     <td>Job Title</td> 
29:     <td>Hire Date</td> 
30:    </tr> 
31:    <% EmployeeDAO em = new EmployeeDAO(); 
32:    Connection ct = ConnectionManager.getInstance().getConnection(); 
33:    ResultSet rs = em.selectByFirstNameRS(empN,ct); 
34:    try { 


An error occurred at line: 31 in the jsp file: /test.jsp 
EmployeeDAO cannot be resolved to a type 
28:     <td>Job Title</td> 
29:     <td>Hire Date</td> 
30:    </tr> 
31:    <% EmployeeDAO em = new EmployeeDAO(); 
32:    Connection ct = ConnectionManager.getInstance().getConnection(); 
33:    ResultSet rs = em.selectByFirstNameRS(empN,ct); 
34:    try { 


An error occurred at line: 32 in the jsp file: /test.jsp 
ConnectionManager cannot be resolved 
29:     <td>Hire Date</td> 
30:    </tr> 
31:    <% EmployeeDAO em = new EmployeeDAO(); 
32:    Connection ct = ConnectionManager.getInstance().getConnection(); 
33:    ResultSet rs = em.selectByFirstNameRS(empN,ct); 
34:    try { 
35:      if(rs != null) {%> 


An error occurred at line: 53 in the jsp file: /test.jsp 
ConnectionManager cannot be resolved 
50:    } catch (Exception e) { 
51:     e.printStackTrace(); 
52:    } finally { 
53:     ConnectionManager.getInstance().releaseConnection(ct); 
54:    }%> 
55:   </table> 
56:    <a href="index.html">Return to search</a> 


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) 


Note The full stack trace of the root cause is available in the Apache Tomcat/6.0.33 logs. 


-------------------------------------------------------------------------------- 

Apache Tomcat/6.0.33 

我一直在寻找通过谷歌,它可以由不具有WEB-INF文件夹内包引起的。我正在运行tomcatIntelliJ IDEA,我想知道是不是应该将已经在文件路径中的包自行移动到创建的WEB-INF文件夹中?如果确实如此,我做错了什么?这两个文件我使用:

的index.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
     "http://www.w3.org/TR/html4/loose.dtd"> 

<html> 
<head> 
    <title>Employee Test Webapp</title> 
</head> 
<body> 
    <h3>Employee Database:</h3> 
    <table> 
     <tr> 
      What is the name of the Employee you want to find? 
     </tr> 
     <tr> 
      <form action="test.jsp" method="post"> 
      <td><input type="text" name="empName"></td> 
       <td><input type="submit" value="search"></td> 
      </form> 
     </tr> 
    </table> 

</body> 
</html> 

而且test.jsp的:

<%@ page import="com.sun.xml.internal.ws.wsdl.writer.document.xsd.Import" %> 
<%@ page contentType="text/html;charset=UTF-8" language="java" %> 
<%@ page import="com.test.dao.*" %> 
<%@ page import="java.sql.Connection" %> 
<%@ page import="com.test.util.ConnectionManager" %> 
<%@ page import="java.sql.ResultSet" %> 
<% String empN = request.getParameter("empName"); %> 
<html> 
<head><title>Employee Test Web App</title></head> 
<body> 
     Your results are: 

     <table cellpadding="15" border="1" style="background-color: #ffffcc;"> 
      <tr> 
       <td>Employee ID</td> 
       <td>First Name</td> 
       <td>Last Name</td> 
       <td>Company Name</td> 
       <td>Department Name</td> 
       <td>Job Title</td> 
       <td>Hire Date</td> 
      </tr> 
      <% EmployeeDAO em = new EmployeeDAO(); 
      Connection ct = ConnectionManager.getInstance().getConnection(); 
      ResultSet rs = em.selectByFirstNameRS(empN,ct); 
      try { 
        if(rs != null) {%> 
         <%while (rs.next()) {%> 
         <tr> 
          <td><%=rs.getInt(1)%></td> 
          <td><%=rs.getString(2)%></td> 
          <td><%=rs.getString(3)%></td> 
          <td><%=rs.getString(4)%></td> 
          <td><%=rs.getString(5)%></td> 
          <td><%=rs.getString(6)%></td> 
          <td><%=rs.getString(7)%></td> 
         </tr><% 
         } 
        }else{ 
         %> <tr>Table empty</tr> <% 
        } 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } finally { 
       ConnectionManager.getInstance().releaseConnection(ct); 
      }%> 
     </table> 
      <a href="index.html">Return to search</a> 
    </body> 
</html> 

对自己进行了一些进口的理念。这里是我的文件路径:

http://i.imgur.com/iJd8H.png

请帮助。

+0

我还没有使用Intellij和Tomcat在一起。但我不相信这是IDE的问题。要检查它,你可以点击Build - > Build“Test.war”爆炸的神器。现在你的proj目录中会有一个out文件夹。打开该文件夹以查看类文件是否使其成为工件。 –

+0

Out文件夹有3个子文件夹:工件,生产和测试。课程正在测试中。那是他们应该在哪里? – Nimchip

+0

如果您创建了war文件,那么在artifact下,应该有一个爆炸war文件。在war文件下,找到web_inf下的类。如果它不起作用,请进入聊天。 –

回答

0

项目结构是正确的,intellij照顾一切。解决错误是必须首先纠正的内部运行时错误的产物。我使用了tomcat日志来找到它。感谢所有你的帮助。

0

这将有助于查看WAR文件或爆炸WAR目录的内容。

通常情况下,IntelliJ并没有将构建路径中的所有内容都复制到WAR中的相应位置,但有时对于某些文件类型,它并不总是会发现变化。在这种情况下,这不应该是一个问题,因为它是一个类文件。我认为它也认为com.test.util.ConnectionManager是一个包。

我的建议是确保在执行Build All之前停止tomcat,并且在没有帮助时(因为我真的不认为它会)检查WAR伪影的设置并确保它是拉入所有正确的文件。

+0

我发布了一张原始图片上的项目结构链接,但这里又是:http://i.imgur.com/iJd8H.png – Nimchip

+0

希望这也有助于:http://i.imgur.com项目结构下的/eZ9ED.png工件 – Nimchip

+0

您需要查看生成的WAR文件或部署到tomcat的爆炸WAR目录中的实际内容。在你的第二个屏幕截图中,看起来应该在你进行构建之后在Test \ out \ artifacts \ Test_war_exploded中。 – ThatAintWorking

相关问题