2 jeffery fly Jeffery_fly 于 2013.12.24 21:20 提问

easy ui datagrid显示数据问题

在页面显示不出查询结果,弹出一个错误框,信息以字符串类型全显示在里面。
jsp代码:
$(function () {
$('#list_data').datagrid({
url:"messages!showMessageInfoList.do",
frozenColumns:[[
{field:'ck',checkbox:true }
]],
columns:[[
{title:'id',field:"id",hidden:'false' ,width:"100px"},
{title:'房号',field:'houseid',width:"50",align:'center' },

{title:'消息标题',field:'title',width:"100",align:'center'},

{title:'消息描述',field:'content',width:"100",align:'center'},

{title:'是否已读',field:'isread',width:"100",align:'center',
formatter:function(val)
{
if(val=="0")
{
return "未读";
}
else if(val=="1")
{
return "已读";
}
}
},

{title:'发布时间',field:'sdate',width:"100",align:'center'}
]])}
action代码:

public void showMessageInfoList() throws Exception{
    String startdate = request.getParameter("sdate");
    String enddate = request.getParameter("edate");

    //当前页
    int currentPage = Integer.parseInt((page == null || page == "0")?"1":page);
    //每页显示
    int nums = Integer.parseInt((rows == null ||rows == "0")?"10":rows);
    //每页开始记录,第一页为1,下一页为num+1
    //int stares = (currentPage-1)*nums;
    List<Messages> list = null;
    try{
        list = mservice.findByPage(currentPage, nums,startdate ,enddate);//把每页数据放进list
    }catch(Exception e){
        e.printStackTrace();
    }
        int total = mservice.getSumPage(startdate ,enddate);
        Map<String ,Object> jsonMap = new HashMap<String ,Object>();
        jsonMap.put("total", total);//存放总记录
        jsonMap.put("rows", list);
        result =  JSON.toJSONStringWithDateFormat(jsonMap,"yyyy-MM-dd");//格式化result  

// result = JSON.toJSONString(jsonMap);//格式化result
System.out.println(list.size());
response.setContentType("text/html;charset=utf-8");
System.out.println(result.length());

        PrintWriter out = response.getWriter();
        out.print(result);
        out.flush();
        out.close();

}

public Messages createDate(){
Messages messages = new Messages();
messages.setTitle(title);
messages.setContent(content);
messages.setSdate(sdate);
messages.setHouseid(houseid);
messages.setIsread(isread);
return messages;

}

CSDN移动问答

Csdn user default icon
上传中...
上传图片
插入图片