-
大小: 434KB文件類型: .7z金幣: 1下載: 0 次發(fā)布日期: 2021-05-16
- 語言: Java
- 標(biāo)簽: 俆守威??SSH??畢業(yè)設(shè)計(jì)??JavaWeb??
資源簡(jiǎn)介
本項(xiàng)目設(shè)計(jì)一個(gè)具有代表性的網(wǎng)上購(gòu)書系統(tǒng),目的是交換學(xué)生或讀者怎樣實(shí)現(xiàn)SSH框架整合,本項(xiàng)目適合于學(xué)生做畢業(yè)設(shè)計(jì),入門中的經(jīng)典之作!導(dǎo)入即可運(yùn)行,本項(xiàng)目數(shù)據(jù)庫采用Sql Server 2005,具體數(shù)據(jù)庫已經(jīng)備份到項(xià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;//當(dāng)前頁
//生成當(dāng)前頁的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;
}
//方法實(shí)現(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);
//購(gòu)物車要返回繼續(xù)購(gòu)買時(shí)需要記住返回的地址
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;
}
}
評(píng)論
共有 條評(píng)論