-
大小: 434KB文件類型: .7z金幣: 1下載: 0 次發(fā)布日期: 2021-05-16
- 語言: Java
- 標簽: 俆守威??SSH??畢業(yè)設(shè)計??JavaWeb??
資源簡介
本項目設(shè)計一個具有代表性的網(wǎng)上購書系統(tǒng),目的是交換學生或讀者怎樣實現(xiàn)SSH框架整合,本項目適合于學生做畢業(yè)設(shè)計,入門中的經(jīng)典之作!導入即可運行,本項目數(shù)據(jù)庫采用Sql Server 2005,具體數(shù)據(jù)庫已經(jīng)備份到項目中!
代碼片段和文件信息
package?org.bookstore.action;
import?java.util.List;
import?java.util.Map;
import?org.bookstore.model.Book;
import?org.bookstore.service.IBookService;
import?org.bookstore.service.ICatalogService;
import?org.bookstore.util.Pager;
import?com.opensymphony.xwork2.ActionContext;
import?com.opensymphony.xwork2.ActionSupport;
public?class?BookAction?extends?ActionSupport{
protected?ICatalogService?catalogService;
public?void?setCatalogService(ICatalogService?catalogService)?{
this.catalogService?=?catalogService;
}
public?String?browseCatalog()?throws?Exception{
List?catalogs=catalogService.getAllCatalogs();
Map?request=(Map)ActionContext.getContext().get(“request“);
request.put(“catalogs“catalogs);
return?SUCCESS;
}
protected?IBookService?bookService;
public?void?setBookService(IBookService?bookService)?{
this.bookService?=?bookService;
}
public?String?newBook()?throws?Exception{
List?books=bookService.getNewBook();
Map?request=(Map)ActionContext.getContext().get(“request“);
request.put(“books“?books);
return?SUCCESS;
}
protected?Integer?catalogid;//獲得圖書類別的ID
private?Integer?currentPage=1;//當前頁
//生成當前頁的get和set方法
public?Integer?getCurrentPage()?{
return?currentPage;
}
public?void?setCurrentPage(Integer?currentPage)?{
this.currentPage?=?currentPage;
}
//生成圖書ID的get和set方法
public?Integer?getCatalogid()?{
return?catalogid;
}
public?void?setCatalogid(Integer?catalogid)?{
this.catalogid?=?catalogid;
}
//方法實現(xiàn)
public?String?browseBookPaging()?throws?Exception{
int?totalSize=bookService.getTotalByCatalog(catalogid);
System.out.println(catalogid);
Pager?pager=new?Pager(currentPagetotalSize);
List?books=bookService.getBookByCatalogidPaging(catalogid?currentPage?pager.getPageSize());
Map?request=(Map)ActionContext.getContext().get(“request“);
request.put(“books“?books);
request.put(“pager“pager);
//購物車要返回繼續(xù)購買時需要記住返回的地址
Map?session=ActionContext.getContext().getSession();
request.put(“catalogid“catalogid);
return?SUCCESS;
}
private?String?bookname;//根據(jù)輸入的書名或部分書名查詢
public?String?getBookname()?{
return?bookname;
}
public?void?setBookname(String?bookname)?{
this.bookname?=?bookname;
}
public?String?searchBook()?throws?Exception?{
List?books?=?bookService.getRequiredBookByName(this.getBookname());
Map?request?=?(Map)ActionContext.getContext().get(“request“);
System.out.println(bookname);
request.put(“books“books);
return?SUCCESS;
}
}
評論
共有 條評論