JSP中带条件的查询分页
[code="java"][b]对于带条件查询的分页,用到的主要是session,在提交时判断是不是第一次提交,如果是session.getAttribute("condition") ==null 则为空,同时创建一个新的这里我们用Map 存放健值对,并将此对象的放入session。 前面我们可以这样写
物料搜索
物料名字: 物料类型
名字 数量 价格 类型 供应商 ${temp.name } ${temp.count } ${temp.price } ${temp.type_id } ${temp.provider_id}
--------------------------- 后台 String pageNum = request.getParameter("pageNum"); String goodsName = request.getParameter("goodsName"); String goodsType = request.getParameter("goodsType"); HttpSession session = request.getSession(); Map condition = (Map) session.getAttribute("condition"); if (condition == null) { condition = new HashMap(); session.setAttribute("condition", condition); } if (goodsName != null) { condition.put("goodsName", goodsName); } if (goodsType != null) { condition.put("goodsType", goodsType); } if (pageNum == null) pageNum = "1"; PageInfo p = new PageInfo(Integer.parseInt(pageNum), 10, "t_s_goods"); dao.getAll(p, condition); request.setAttribute("page", p); request.getRequestDispatcher("goods/goods_list.jsp").forward(request,response);[/b][code="java"][/code][code="java"][/code][/code]