58,454
社区成员
发帖
与我相关
我的任务
分享
package com.sterning.books.web.actions;
import java.util.Collection;
import com.sterning.books.model.Books;
import com.sterning.books.services.iface.IBooksService;
import com.sterning.commons.AbstractAction;
import com.sterning.commons.Pager;
import com.sterning.commons.PagerService;
public class BooksAction extends AbstractAction {
private IBooksService booksService;
private PagerService pagerService;
private Books book;
private Pager pager;
protected Collection availableItems;
protected String currentPage;
protected String pagerMethod;
protected String totalRows;
protected String bookId;
protected String queryName="1";
protected String queryValue="1";
protected String searchName;
protected String searchValue;
protected String queryMap;
public String list() throws Exception {
if(queryMap ==null||queryMap.equals("")){
}else{
String[] str=queryMap.split("~");
this.setQueryName(str[0]);
this.setQueryValue(str[1]);
}
//System.out.println("asd1"+this.getQueryValue());
//这里出错,网上的例子来的。。。。。: http://blog.csdn.net/zhicc/archive/2009/07/28/4386849.aspx
int totalRow=booksService.getRows(this.getQueryName(),this.getQueryValue());
pager=pagerService.getPager(this.getCurrentPage(), this.getPagerMethod(), totalRow);
this.setCurrentPage(String.valueOf(pager.getCurrentPage()));
this.setTotalRows(String.valueOf(totalRow));
availableItems=booksService.getBooks(this.getQueryName(),this.getQueryValue(),pager.getPageSize(), pager.getStartRow());
this.setQueryName(this.getQueryName());
this.setQueryValue(this.getQueryValue());
this.setSearchName(this.getQueryName());
this.setSearchValue(this.getQueryValue());
return SUCCESS;
}
package com.sterning.books.web.actions;
import java.util.Collection;
import com.sterning.books.model.Books;
import com.sterning.books.services.iface.IBooksService;
import com.sterning.commons.AbstractAction;
import com.sterning.commons.Pager;
import com.sterning.commons.PagerService;
public class BooksAction extends AbstractAction {
private IBooksService booksService;
private PagerService pagerService;
private Books book;
private Pager pager;
protected Collection availableItems;
protected String currentPage;
protected String pagerMethod;
protected String totalRows;
protected String bookId;
protected String queryName="1";
protected String queryValue="1";
protected String searchName;
protected String searchValue;
protected String queryMap;
public String list() throws Exception {
//if(queryMap ==null||queryMap.equals("")){
//如果queryMap 为空时,queryMap.equals("")这句会报空指针错,一般改为("").equals(queryMap)
//就不会报这个错了。
//或者改为:
if(queryMap ==null){
}else if(queryMap.equals("")){
}else{
String[] str=queryMap.split("~");
this.setQueryName(str[0]);
this.setQueryValue(str[1]);
}
//System.out.println("asd1"+this.getQueryValue());
//这里出错,网上的例子来的。。。。。: http://blog.csdn.net/zhicc/archive/2009/07/28/4386849.aspx
int totalRow=booksService.getRows(this.getQueryName(),this.getQueryValue());
pager=pagerService.getPager(this.getCurrentPage(), this.getPagerMethod(), totalRow);
this.setCurrentPage(String.valueOf(pager.getCurrentPage()));
this.setTotalRows(String.valueOf(totalRow));
availableItems=booksService.getBooks(this.getQueryName(),this.getQueryValue(),pager.getPageSize(), pager.getStartRow());
this.setQueryName(this.getQueryName());
this.setQueryValue(this.getQueryValue());
this.setSearchName(this.getQueryName());
this.setSearchValue(this.getQueryValue());
return SUCCESS;
}