无框架加载Table表中数据(二)

这次是利用JSTL,点击查询按钮后下面的TABLE刷新内容,并分页:

无框架加载Table表中数据(二)_第1张图片

jsp向后台发送请求:

        function search(){
		var account=$("#account").val().trim();
		var company=$("#company").val().trim();
		var begin_time=$("#begin_time").datebox('getValue'); 
		var end_time=$("#end_time").datebox('getValue'); 
		var tax_no=$("#tax_no").val().trim();
		window.location.href="<%=basePath %>customer/account/findReportingResult?account="+account+"&company="+company+"&begin_time="+begin_time+"&end_time="+end_time+"&tax_no="+tax_no;	
	}
后台接收查询参数返回结果:

	/**
	 * 查找所有下属企业
	 * @throws IOException 
	 */
	@RequestMapping(value="/findReportingResult")

	public String findReportingResult(Integer pageNum_,String account,String company,String begin_time,String end_time,String tax_no,HttpServletRequest request,HttpServletResponse response) throws IOException{
		Map map=new HashMap();
		//int start = (page - 1) * rows;
		int pageNum=1;
		if(pageNum_!=null){
			pageNum=pageNum_.intValue();
		}
		map.put("company", company);
		map.put("account", account);
		map.put("begin_time", begin_time);
		map.put("end_time", end_time);
		map.put("tax_no", tax_no);
		List orderListall = new ArrayList();
		//int count=0;
		try {
			orderListall = registerService.findReportingResult(map);
			//count = payService.CountOrder(map);
			int isEnd=1;//最后一页标识为1
			int isStart=1;//开始一页标识为1
			if(orderListall.size()>0){
				if(pageNum==0){
					pageNum=1;
				}
				isEnd=pageNum==(orderListall.size()-1)/5+1?1:0;
				isStart=pageNum==1?1:0;
				int pageStart=5*(pageNum-1);//当前页的开始条数
				int pageEnd=5*pageNum;//当前页的结束条数
				if(5*pageNum>orderListall.size()){
					pageEnd=orderListall.size();
				}
			//System.out.println(orderListall);
			List orderList=orderListall.subList(pageStart, pageEnd);
			//System.out.println(orderList);
			request.setAttribute("orderList", orderList);
			}
			request.setAttribute("isEnd", isEnd);
			request.setAttribute("isStart", isStart);
			request.setAttribute("pageNum", pageNum);
			request.setAttribute("account", account);
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}			
		return "customer/reportingResults";
	}
这时候要注意,刷新表中数据要注意JSTL表达式的使用,在使用时要加:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

table的HTML:

 
	
无已办记录
序号 纳税人识别号 纳税人名称 纳税企业名称 申报结果 申报结果说明
${item.declaration_id} ${item.tax_no} ${item.taxpayer} ${item.company} ${item.result} ${item.info}
如果查找结果非常多的话,所有结果都放在一页非常难看,可以通过分页来解决,

在table的下面加了个上一页和下一页,每页显示的行数默认为5:


    


    








你可能感兴趣的:(前端,jsp,分页,jstl)