資源簡介
用SSH三大框架:即Spring、Struts、Hibernate,實現的圖書管理系統,內附論文報告可供參考,使用IDE:MyEclipse,環境需要配置MySQL和Tomcat。
代碼片段和文件信息
package?org.action;
import?java.io.File;
import?java.io.FileInputStream;
import?java.util.List;
import?java.util.Map;
import?javax.servlet.ServletOutputStream;
import?javax.servlet.http.HttpServletResponse;
import?org.apache.struts2.ServletActionContext;
import?org.apache.struts2.interceptor.RequestAware;
import?org.model.Book;
import?org.service.BookService;
import?org.service.LendService;
import?org.springframework.context.ApplicationContext;
import?org.springframework.context.support.ClassPathxmlApplicationContext;
import?org.tool.Pager;
import?com.opensymphony.xwork2.ActionContext;
import?com.opensymphony.xwork2.ModelDriven;
import?com.opensymphony.xwork2.Preparable;
public?class?BookAction?implements?RequestAware?ModelDriven?Preparable{
private?int?pageNow=1;??? ?//初始頁面為第一頁
private?int?pageSize=4;??? ?//每頁顯示4天記錄
private?String?message;
private?File?photo;
private?Book?book=null;
private?BookService?bookService=null;
private?LendService?lendService=null;
public?void?init(){
ApplicationContext?ctx?=?new?ClassPathxmlApplicationContext(“applicationContext.xml“);
????bookService?=?(BookService)?ctx.getBean(“bookService“);
????lendService?=?(LendService)?ctx.getBean(“lendService“);
}
public?String?addBook()?throws?Exception{
init();
Book?bo=bookService.selectBook(book.getISBN());
if(bo!=null){?????????????? ? //判斷要添加的圖書是否已經存在
this.setMessage(“ISBN已經存在!“);
return?“success“;
}else{
// Book?b=new?Book();
// b.setISBN(book.getISBN());
// b.setBookName(book.getBookName());
// b.setAuthor(book.getAuthor());
// b.setPublisher(book.getPublisher());
// b.setPrice(book.getPrice());
// b.setCnum(book.getCnum());
// b.setSnum(book.getCnum());
// b.setSummary(book.getSummary());
if(this.getPhoto()!=null){
FileInputStream?fis=new?FileInputStream(this.getPhoto());
byte[]?buffer=new?byte[fis.available()];
fis.read(buffer);
book.setPhoto(buffer);
}
if(bookService.addBook(book)){
this.setMessage(“添加成功!“);
return?“success“;
}else{
this.setMessage(“添加失敗!“);
return?“success“;
}
??}
}
public?String?deleteBook()?throws?Exception{
// LendDao?lendDao?=?new?LendDao();
init();
Book?bo=bookService.selectBook(book.getISBN());
if(bo==null){?????????????//首先判斷是否存在該圖書
this.setMessage(“要刪除的圖書不存在!“);
return?“success“;
}else?if(lendService.selectByBookISBN(book.getISBN())!=null){
this.setMessage(“該圖書已經被借出故不能刪除圖書信息!“);
return?“success“;
}
bookService.deleteBook(book);
this.setMessage(“刪除成功!“);
return?“success“;
}
public?String?selectBook()?throws?Exception{
init();
Book?onebook=bookService.selectBook(book.getISBN());
if(onebook==null){
this.setMessage(“不存在該圖書!“);
return?“success“;
}
Map?request=(Map)?ActionContext.getContext().get(“request“);
request.put(“onebook“?onebook);
return?“success“;
}
public?String?getImage()?throws?Exception{
init();
HttpServl
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4575??2017-08-14?05:50??BookManage-master\book_ssh\.classpath
?????文件???????1005??2017-08-14?05:50??BookManage-master\book_ssh\.project
?????文件????????491??2017-08-14?05:50??BookManage-master\book_ssh\.settings\.jsdtscope
?????文件????????357??2017-08-14?05:50??BookManage-master\book_ssh\.settings\org.eclipse.jdt.core.prefs
?????文件????????468??2017-08-14?05:50??BookManage-master\book_ssh\.settings\org.eclipse.wst.common.component
?????文件????????335??2017-08-14?05:50??BookManage-master\book_ssh\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2017-08-14?05:50??BookManage-master\book_ssh\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2017-08-14?05:50??BookManage-master\book_ssh\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件?????????93??2017-08-14?05:50??BookManage-master\book_ssh\.settings\org.jboss.ide.eclipse.as.core.prefs
?????文件???????4259??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\applicationContext.xm
?????文件????????171??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\db.properties
?????文件???????1016??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\hibernate.cfg.xm
?????文件???????1015??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\action\BookAction-validation.xm
?????文件???????8251??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\action\BookAction.class
?????文件???????6311??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\action\LendAction.class
?????文件???????3117??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\action\LoginAction.class
?????文件????????795??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\dao\ba
?????文件???????6022??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\dao\BookDao.class
?????文件???????5654??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\dao\LendDao.class
?????文件???????3317??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\dao\LoginDao.class
?????文件???????2756??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\dao\StudentDao.class
?????文件???????1036??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\db\DBConn.class
?????文件???????2065??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\model\Book.class
?????文件???????1400??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\model\Book.hbm.xm
?????文件???????1479??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\model\Lend.class
?????文件???????1065??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\model\Lend.hbm.xm
?????文件???????1150??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\model\Login.class
?????文件????????809??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\model\Login.hbm.xm
?????文件???????1853??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\model\Student.class
?????文件???????1277??2017-08-14?05:50??BookManage-master\book_ssh\build\classes\org\model\Student.hbm.xm
............此處省略153個文件信息
- 上一篇:汽車配件進銷存系統
- 下一篇:最完整的INTOUCH教程
評論
共有 條評論