Topic: [实战+疑问]一个Struts+Hibernate的例子 |
Print this page |
1.[实战+疑问]一个Struts+Hibernate的例子 | Copy to clipboard |
Posted by: seaboy Posted on: 2004-09-01 10:32 介绍:很简单的一个功能,添加一段内容到数据库, 浏览添加的内容。 添加页面:input.jsp 浏览页面:list.jsp 数据库结构: CREATE TABLE book ( 目录结构如下:
下面是相关代码: |
2.Re:[实战+疑问]一个Struts+Hibernate的例子 [Re: seaboy] | Copy to clipboard |
Posted by: seaboy Posted on: 2004-09-01 10:34 inc.jsp
/form/input.jsp
list.jsp
|
3.Re:[实战+疑问]一个Struts+Hibernate的例子 [Re: seaboy] | Copy to clipboard |
Posted by: seaboy Posted on: 2004-09-01 10:35 /com/book/struts/action InputAction.java package com.book.struts.action; com/book/struts/form InputForm.java
|
4.Re:[实战+疑问]一个Struts+Hibernate的例子 [Re: seaboy] | Copy to clipboard |
Posted by: seaboy Posted on: 2004-09-01 10:37 AbstractBook.java
Book.java
Book.hbm.xml
|
5.Re:[实战+疑问]一个Struts+Hibernate的例子 [Re: seaboy] | Copy to clipboard |
Posted by: seaboy Posted on: 2004-09-01 10:39 SessionFactory.java
BookService.java
|
6.Re:[实战+疑问]一个Struts+Hibernate的例子 [Re: seaboy] | Copy to clipboard |
Posted by: seaboy Posted on: 2004-09-01 10:43 很多内容都是参照别人的例子写的。 感觉没什么错, 但是部署到tomcat,就是报错,刚刚接触, 想用个简单的例子实践一下,但是老失败。实在是受打击。 还请高手看看。哪里有问题。谢谢 提交input之后,tomcat提示:
看来好像是SessionFactory出问题了,我看别人也差不多是这种模式写的呢。实在想不出什么问题。 单独试验Struts or Hibernate,好像问题不多,但是一结合起来。问题太多。 即使是个很简单的例子,都问题很多。真是.... |
7.Re:[实战+疑问]一个Struts+Hibernate的例子 [Re: seaboy] | Copy to clipboard |
Posted by: seaboy Posted on: 2004-09-01 10:47 SessionFactory 好像并不能建立session??? 现在数据库有数据,浏览list,也报错, type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause java.lang.NullPointerException com.book.hibernate.SessionFactory.currentSession(SessionFactory.java:56) com.book.hibernate.BookService.getBookList(BookService.java:117) org.apache.jsp.list_jsp._jspService(list_jsp.java:117) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) |
8.Re:[实战+疑问]一个Struts+Hibernate的例子 [Re: seaboy] | Copy to clipboard |
Posted by: hua123456 Posted on: 2004-09-15 17:43 关注中.. |
9.Re:[实战+疑问]一个Struts+Hibernate的例子 [Re: seaboy] | Copy to clipboard |
Posted by: ming500 Posted on: 2004-09-15 18:10 好 |
10.Re:[实战+疑问]一个Struts+Hibernate的例子 [Re: seaboy] | Copy to clipboard |
Posted by: cyfboy Posted on: 2004-10-12 14:55 关注中!! |
11.Re:[实战+疑问]一个Struts+Hibernate的例子 [Re: seaboy] | Copy to clipboard |
Posted by: LostParadise Posted on: 2004-10-14 12:55 我只是花了2分钟看了一下,不一定准确。 session = SessionFactory.currentSession(); 如果在没有初始化session之前就运行到这里,一定会出现java.lang.NullPointerException的。所以要确保先创建了一个Seesion先。具体你查查hibernate的教程吧。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |