chenhuaih 2015-04-14 04:33 采纳率: 0%
浏览 2957

使用jquery easyui datagrid请求servlet没有反应

我现在想使用jquery easyui datagrid做一个分页,功能,打算通过url请求后台的servlet返回json数据,可是怎么弄servlet就是没反应,望大侠们帮一下忙,感激不尽!!
代码如下:

 datagrid代码:
 <script type="text/javascript">
 $(function(){
 $('#list_data').datagrid({
 title:'日志列表',
iconCls:'icon-edit',    //图标
width:700,
 height:'auto',
 nowrap:false,
 striped:true,
 border:true,
 collapsible:false,
 fit:true,
 url:'listApp',    //就是在这里没反应    listApp是我的servlet
 remoteSort:false,
 idField:'fldId',
 singleSelect:true,
 collapsible:true,
 pagination:true,
 rownumbers:true,
 frozenColumns:[[
              {field:'ck',checkbox:true}        
       ]],
       toolbar:[{
        text:'添加',
        iconCls:'icon-add',
        handler:function(){
        openDialog("add_dialog","add");
        }
       }, '-', { 
             text: '修改', 
             iconCls: 'icon-edit', 
             handler: function() { 
                 openDialog("add_dialog","edit"); 
             } 
         }, '-',{ 
             text: '删除', 
             iconCls: 'icon-remove', 
             handler: function(){ 
                 delAppInfo(); 
             }  
         }],
 });
   var p=$('#list_data').datagrid('getPager');
   $(p).pagination({
   pageSize:10,
   pageList:[5,10,15],
   beforePageText:'第',
   afterPageText:'页    共{pages}页',
   displayMsg:'当前显示 {from} - {to} 条记录   共{total} 条记录',
 });
 </script>
 <body>
 <center>
  <table class="easyui-datagrid" id="list_data">  
     <thead>  
         <tr>
             <th data-options="field:'id'">id</th>   
             <th data-options="field:'ip'">ip</th> 
             <th data-options="field:'picture1Name'">图片1</th>
             <th data-options="field:'picture2Name'">图片2</th>  
             <th data-options="field:'picture1'">数据库图片1</th>  
             <th data-options="field:'picture2'">数据库图片2</th>
             <th data-options="field:'simility'">相似度</th>
             <th data-options="field:'time'">上传时间</th>    
         </tr>  
     </thead>  
     <tbody>......

下面是servlet代码:
@WebServlet("/listApp")
public class listApp extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("---------执行servlet-----------");
String page=request.getParameter("page");
String rows=request.getParameter("rows");
System.out.println(page);
System.out.println(rows);
int intPage = Integer.parseInt((page == null || page == "0") ? "1":page);
int number = Integer.parseInt((rows == null || rows == "0") ? "10":rows);
int start=(intPage-1)*number;
getuploadLogService service=new getuploadLogServiceImpl();
ArrayList logs=service.getpageData(start, number);
Map jsonMap=new HashMap();
jsonMap.put("total", service.getCount());
jsonMap.put("rows",logs);
response.setContentType("application/json");
JSONObject result=JSONObject.fromObject(jsonMap);
System.out.println(result.toString());
response.getWriter().write(result.toString());
}

  • 写回答

2条回答 默认 最新

  • Go 旅城通票 2015-04-14 05:50
    关注

    开发工具看下返回的数据格式是否正确,一般结构是
    {"total":总数量,"rows":[{....},....]}

    这种结构的数据

    评论

报告相同问题?

悬赏问题

  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘