日期:2014-05-18  浏览次数:20718 次

JSP+HIBERNATE问题
我用JSP+HIBERNATE开发项目。
Hibernate有关的类全部编译成功,并且放到了WEB-INF/classes/mypack里。
有关Hibernate的XML文件也都配置完毕。
Hibernate包下的hibernate2.jar和LIB目录下的所有JAR都放到了项目的WEB-INF/LIB目录下。
在JSP中引用了Hibernate的持久类和逻辑类。但在启动后页面报错

HTTP   Status   500   -  

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

type   Exception   report

message  

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

exception  

javax.servlet.ServletException:   net/sf/hibernate/HibernateException
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:272)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root   cause  

java.lang.NoClassDefFoundError:   net/sf/hibernate/HibernateException
java.lang.Class.getDeclaredConstructors0(Native   Method)
java.lang.Class.privateGetDeclaredConstructors(Unknown   Source)

JSP代码如下:customer.jsp

<%@   page   import= "java.sql.*,java.util.* "   errorPage= "error.jsp "%>  

<jsp:useBean   id= "cm "   class= "mypack.Customer "   scope= "page ">

<jsp:setProperty   name= "cm "   property= "* "/>

</jsp:useBean>

<jsp:useBean   id= "cb "   class= "mypack.CustomerBean "   scope= "page "/>

<html> <body> <center>

<%  

try

{

if(cm.getId().equals(null)||cm.getId().equals( " "));

else   cb.addCourse(course);


%>

成功添加了Customer: <br>

username: <%=cm.getUsername()%>

Id: <%=cm.getId()%>

<%

}

catch(Exception   e)

{

}  

%>  


<hr>

<br> ::增加一个Customer:: <br>

<form   action= "customer.jsp "   method= "get "   name= "add ">

id: <input   type=text   name= "id "> <br>

username: <input   type=text   name= "username "> <br>

<input   type=submit   value= "submit "> <br>

</form>

<hr>

::按名字模糊查找:: <br>

<form   action= "queryCustomer.jsp "   method= "get "   name= "queryByName ">

username: <input   type=text   name= "username "> <br>

<input   type=submit   value= "query "> <br>

</form>

<hr>

::删除一个Customer:: <br>

<form   action= "deleteCustomer.jsp "   method= "get "   name= "queryByName ">

id: <input &n