首页 新闻 会员 周边

ligerUI分页问题

0
悬赏园豆:5 [待解决问题]
@RequestMapping("/show.action")
    public String show(Model model,HttpServletResponse response){
        int i = 1;
        int p = 30;
List<Userinfo> userinfoFY = userInfoService.findFy(i,p);
        JSONArray jsonArray = JSONArray.fromObject(userinfoFY);
int totalCount=userInfoService.getTotalCount();//所有记录数
String rst = "";
        StringBuilder sb = new StringBuilder(); //修正格式符合grid要求的json格式
        sb.append("{\"Rows\":");
        sb.append(jsonArray);
        sb.append(",\"Total\":");
        sb.append(totalCount+"}");//追加所有记录数到json
        rst = sb.toString();
  response.setContentType("application/json;charset=UTF-8");  
        PrintWriter printWriter;
        try {
            printWriter = response.getWriter();
            printWriter.print(rst); //后台得到json数据 
            printWriter.flush();  
            printWriter.close();  
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }  
    return "jsp/back/documents/v_list";
    }
 <script type="text/javascript">
        var grid = null;
        $(function () {
            grid = $("#maingrid4").ligerGrid({
                columns: [
                { display: '主键', name: 'id', align: 'left', width: 120 },
                { display: '公司名', name: 'username', minWidth: 60 },
                { display: '联系名', name: 'userpass', width: 50,align:'left' }, 
                { display: '城市', name: 'state' }
                ],  pageSize:30,where : f_getWhere(),
                data: $.extend(true,{},rst), 
                width: '100%',height:'100%'
                url:"show.action",
            });


            $("#pageloading").hide();
        });

后台得到的数据,怎样在前台得到展现呢? 
目前 页面报错 严重: Exception initializing page context 
java.lang.IllegalStateException: Cannot create a session after the response has been committed

love_zongming的主页 love_zongming | 初学一级 | 园豆:194
提问于:2013-07-27 15:54
< >
分享
所有回答(2)
0

很明显么  session不能再response提交后创建,你写入的json数据信息默认是放在request中的 而不是在session中的 你这个前台框架我不太懂 ,如果这个前台框架是在session中取得数据 那么肯定取不到数据。如果是ajax请求的话 我以前的方案是直接返回对象,前台是可以拿到这个对象进行json 解析的 

zm112358 | 园豆:213 (菜鸟二级) | 2013-08-01 18:33
0

去掉 

data: $.extend(true,{},rst), 

  url:"show.action",  路径前加上项目名
love_zongming | 园豆:194 (初学一级) | 2013-08-02 00:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册