开发者社区> 问答> 正文

求助使用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());
}

展开
收起
吴孟桥 2016-05-31 14:48:23 4523 0
1 条回答
写回答
取消 提交回答
  • 如果没进servlet,那说明你的datagrid的url写的不对,你可以试试在浏览器里面直接输入完整的url请求,看能不能进servlet。

    2019-07-17 19:21:57
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载