easyUI datagrid赋值问题

因为前面是查询全部 没问题 但是现在加了时间条件查询 我只要查询数据库没有的空记录后

我再查数据库有的 或者全部的记录后台都可以查出来 但是datagrid不会显示 并且后台
还会报错 数组越界
我后台是用的List集合传的值,后台代码:
public List Query(String queryTime) {
String hql = "";
List list = new ArrayList();
if(queryTime.equals("")||queryTime==null){
hql="from Gasorder2";
}else{
hql="from Gasorder2 where buyGasTime like '%"+queryTime+"%'";
}
try {
Query query = session.createQuery(hql);
list = query.list();
} catch (Exception e) {
e.printStackTrace();
}finally{
session.close();
}

    return list;
}
datagrid数据:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>

<%@ page import="Model.Gasorder2" %>
<%@ page import="dao.select" %>
<%@ page import="idao.iselect" %>
<%
String queryTime= request.getParameter("data").trim();
System.out.println("queryTime:"+queryTime);

//List<Object[]> list = new ArrayList<Object[]>();
List<Gasorder2> list = new ArrayList<Gasorder2>();
iselect dao = new select();
list = dao.Query(queryTime);

//获取客户端传递的分页参数
Integer pageSize = Integer.parseInt(request.getParameter("rows"));

//默认参数rows表示每页显示记录数
Integer pageNumber = Integer.parseInt(request.getParameter("page"));
//默认参数page表示当前页数
StringBuilder builder = new StringBuilder("{\"total\":"+list.size()+",\"rows\":[");
//计算分页开始记录数
int start  = (pageNumber-1)*pageSize;
//计算分页结束记录数
int end = start+pageSize;

//根据分页起始参数构建当前页的列表数据
for(int i=start;i<end && i<list.size();i++){
    System.out.println("数组大小:"+list.size());
    Gasorder2 gn = list.get(i);
    //System.out.println(gn.getBuyerAddress()+"~~~~~~"+i);
     String buyGasStatus = "";
     if(gn.getStatus().equals(11)){
        buyGasStatus = "写卡成功";
     }else{
        buyGasStatus = gn.getStatus().toString();
     }
     builder.append("{\"terminalName\":\""+gn.getTerminalName()
                    +"\",\"terminalId\":\""+gn.getTerminalId()
                    +"\",\"buyGasVolume\":\""+gn.getBuyGasVolume()
                    +"\",\"buyGasMoney\":\""+gn.getBuyGasMoney()
                    +"\",\"buyGasTime\":\""+gn.getBuyGasTime()
                    +"\",\"takePayMsg\":\""+gn.getTakePayMsg()
                    +"\",\"buyerAddress\":\""+gn.getBuyerAddress()
                    +"\",\"buyerName\":\""+gn.getBuyerName()
                    +"\",\"priceName\":\""+gn.getPriceName()
                    +"\",\"status\":\""+buyGasStatus
                    +"\",\"userCode\":\""+gn.getUserCode()
                    +"\",\"watchManufacturer\":\""+gn.getWatchManufacturer()
                    +"\",\"flowId\":\""+gn.getFlowId()
                    +"\"},");
    }

list.clear();

String gridJSON = builder.toString();
if(gridJSON.endsWith(",")){
    gridJSON = gridJSON.substring(0,gridJSON.lastIndexOf(","));
}
out.print(gridJSON.toString()+"]}");
System.out.println(gridJSON.toString()+"]}");

%>

2个回答

第一次查询 我输入条件 可以正常显示数据 第二次查询 输入正确的添加也没问题 但是我只要 输入错的条件或空条件查询就会报错:
2017-6-28 18:40:45 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [jsp] in context with path [/changjiGas] threw exception [java.lang.ArrayIndexOutOfBoundsException] with root cause
java.lang.ArrayIndexOutOfBoundsException

报错以后我就算输入正确的查询条件 后台可以查询出数据 但是datagrid前台就不会显示

图片说明

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!