📄 bookaction.java
字号:
package org.yangkang.bookshop.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.yangkang.bookshop.service.impl.BookService;
import org.yangkang.bookshop.util.Page;
import org.yangkang.bookshop.vo.Book;
import org.yangkang.bookshop.vo.Catalog;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class BookAction extends ActionSupport {
protected BookService bookservice;
private int currentpage=1;
private int totalsize;
protected Catalog catalog;
protected Integer catalogId;
public Catalog getCatalog() {
return catalog;
}
public void setCatalog(Catalog catalog) {
this.catalog = catalog;
}
public BookService getBookservice() {
return bookservice;
}
public void setBookservice(BookService bookservice) {
this.bookservice = bookservice;
}
@SuppressWarnings("unchecked")
public String execute() throws Exception{
HashMap<Integer,String> map = bookservice.getAllCatalogIdAndname();
// System.out.println("搜索到的图书arr_catalogId的类型是"+arr_catalogId.getClass());
// System.out.println("搜索到的图书的大小是"+arr_catalogId.size());
if(map.size()!=0){
Map request = (Map)ActionContext.getContext().get("request");
System.out.println("HashMap:"+map);
request.put("catalog", map);
// request.put("arr_catalogname", arr_catalogname);
// request.put("arr_catalogId", arr_catalogId);
return SUCCESS;
}
return ERROR;
}
@SuppressWarnings("unchecked")
public String book_search() throws Exception{
try{
totalsize = bookservice.getBook(getCatalogId()).size();
System.out.println("搜索到的该类图书的总数量是:"+totalsize);
Page pager = new Page(currentpage,totalsize);
System.out.println("搜索到的图书的类型是:"+getCatalogId());
ArrayList<Book> book_arr = bookservice.getPage_Book(catalogId, pager.getPagesize(), currentpage);
System.out.println("pager.getTotalpage():"+pager.getTotalpage());
System.out.println("pager.isHasfistpage():"+pager.isHasfistpage());
System.out.println("pager.isHasnextpage():"+pager.isHasnextpage());
// ArrayList<Book> book_arr = bookservice.getBook(getCatalogId());
// System.out.println("图书类型为:"+getCatalogname());
System.out.println("搜索到的该面的图书的数量是:"+book_arr.size());
// System.out.println("搜索到的图书的数量是:"+catalog.getCatalogId());
if(book_arr.size()>0){
Map request = (Map)ActionContext.getContext().get("request");
Map reque = (Map)ActionContext.getContext().get("request");
Map session = (Map)ActionContext.getContext().getSession();
session.put("catalogId", catalogId);
request.put("book", book_arr);
reque.put("pager", pager);
return SUCCESS;
}
return ERROR;
}
catch(Exception e){
e.printStackTrace();
return ERROR;
}
// System.out.println("搜索到的图书的类型是"+catalogId);
// return ERROR;
}
public Integer getCatalogId() {
return catalogId;
}
public void setCatalogId(Integer catalogId) {
this.catalogId = catalogId;
}
public int getCurrentpage() {
return currentpage;
}
public void setCurrentpage(int currentpage) {
this.currentpage = currentpage;
}
public int getTotalsize() {
return totalsize;
}
public void setTotalsize(int totalsize) {
this.totalsize = totalsize;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -