bookaction.java
来自「webWork+Spring+Hibernate整合开发网络书城,通过这个项目」· Java 代码 · 共 79 行
JAVA
79 行
package org.thj.bookstore.action;
import java.util.List;
import java.util.Map;
import org.thj.bookstore.service.IBookService;
import org.thj.bookstore.service.ICatalogService;
import org.thj.bookstore.util.Pager;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
@SuppressWarnings("serial")
public class BookAction extends ActionSupport {
protected ICatalogService catalogService;
protected IBookService bookService;
protected Integer catalogid;
private Integer currentPage=1;
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
public Integer getCatalogid() {
return catalogid;
}
public void setCatalogid(Integer catalogid) {
this.catalogid = catalogid;
}
public ICatalogService getCatalogService() {
return catalogService;
}
public void setCatalogService(ICatalogService catalogService) {
this.catalogService = catalogService;
}
public IBookService getBookService() {
return bookService;
}
public void setBookService(IBookService bookService) {
this.bookService = bookService;
}
@SuppressWarnings("unchecked")
public String browseCatalog() throws Exception {
List catalogs = catalogService.getAllCatalogs();
Map request = (Map)ActionContext.getContext().get("request");
request.put("catalogs",catalogs);
return SUCCESS;
}
@SuppressWarnings("unchecked")
public String browseBook() throws Exception {
int totalSize = bookService.getTotalByCatalogid(catalogid);
Pager pager = new Pager(currentPage,totalSize);
List books = bookService.getBookByCatalogid(catalogid, currentPage, pager.getPageSize());
Map request = (Map)ActionContext.getContext().get("request");
Map session = ActionContext.getContext().getSession();
session.put("catalogid",catalogid);
request.put("books",books);
request.put("pager",pager);
return SUCCESS;
}
public String searchBook() throws Exception {
return null;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?