Java另一种分页技术
整体系统采用Java中Spring ,Struts, Hibernate组成。
在Action中:
public ActionForward orgview(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) {
// TODO Auto-generated method stub
ActionForward forward = new ActionForward("strpath");
HttpSession session=request.getSession();
String usrid=(String) session.getAttribute("uid");
BxGoods goods=new BxGoods(); //表名
String whe_str=" where c.collectType=0 and c.userId='"+usrid+"'"; //查询的SQL语句
String tableName=" BxCollectGoods as c "; //表名
int dipage =1;
int pageSize =10;
int count = currentPage.allRecord(tableName, whe_str);
int allPage = currentPage.allPage(count, pageSize);
Object d=request.getParameter("d");
if(d!=null)
dipage=Integer.valueOf(d.toString());
List list_cg = currentPage.currentPage(tableName, whe_str, dipage, pageSize, allPage);
List list=new ArrayList();
Iterator iter=list_cg.iterator();
while(iter.hasNext()){
BxCollectGoods cg =(BxCollectGoods) iter.next();
CollectGoods cgBean=new CollectGoods();
String collectname = cg.getCollectName();
String collectId = cg.getCollectId();
goods =goodsDAO.findById(cg.getCollectId());
BxUser bx_user = userDAO.findById(goods.getUserId());
cgBean.setSellerName(bx_user.getUserName());
BxUser user =userDAO.findById(cg.getUserId());
cgBean.setBuyId(cg.getUserId());
cgBean.setCollectName(cg.getCollectName());
cgBean.setCollectType(cg.getCollectType());
cgBean.setRecaddTime(cg.getAddTime());
cgBean.setCollectId(cg.getCollectId());
cgBean.setShopPrice(goods.getShopPrice());
cgBean.setGoodsName(goods.getGoodsName());
cgBean.setRecId(cg.getRecId());
cgBean.setGoodsImg(goods.getGoodsThumb());
list.add(cgBean);
}
request.setAttribute("list", list);
request.setAttribute("d",dipage);
request.setAttribute("count",count);
request.setAttribute("allPage",allPage
相关文档:
正则表达式是字符串处理的终极武器,本文以一个具体题目简介java对正则表达式的支持。
题目:将一个字符串中的形如href=“XXXX”和 src=“XXXX”的部分取出,打印。
处理正则表达式主要用到java.util.regex.Matcher和 java.util.regex.Pattern两个类。
\\测试用的字符串
String source= "...h ......
public static void replaceString(String source,String oldStr,String newStr){
System.out.println(source);
String result = source.replaceAll("(?i)"+oldStr
, newStr); //大小写不敏 ......
StringTokenizer 这个类其实真正项目里面恐怕很少会用吧?但是这个类真的很实用,因为它可以根据自己的方式按照一定的规则来拆分一个字符串
String s = new String("The Java platform is the ideal platform for network computing");
//默认的构造函数,会 ......
Java的数据结构有哪些?Map与Set的本质区别是什么?
分析:Java常见的数据结构有Collection和Map,其中Collection接口下包括List和Set接口,其下又有多个实现类如List下有ArrayList、LinkedList和Vector等实现类,Set下有HashSet、LinkedSet等实现类和SortedSet接口,HashSet下有LinkedHashSet子类,SortedSet接口下有Tre ......