2015-10-19 41 views
0

我要創建這樣一個div在我的表:queryParams舉表

var tabla = $('<table id="tablaConteo2"></table>'); 
var thead = $('<thead></thead>'); 
var enc = $('<tr> <th></th> <th></th> <th></th> <th></th> <th></th> </tr>'); 
thead.appendTo(tabla); 
enc.appendTo(thead); 
tabla.appendTo('#tablaDatosToma2'); 
var $tabla = $('#tablaConteo2'); 

,然後我用this library 初始化像這樣的表:

$tabla.bootstrapTable({ 
        height: 200, 
        url: 'BuscarCodigo', 
        method: 'post', 
        queryParams: function(p){ 
        return{ 
         codigoProducto : $('#codigoToma2').val(), 
         bodegaID: $('#bodega').val() 
        }; 

       }, 
       pagination: true, 
       pageSize: 50, 
       pageList: [10, 25, 50, 100, 200], 
       showRefresh: true, 
      columns: [ 
      { 
       field: 'codigoProducto', 
       title: 'C\u00F3digo' 
      }, 
      { 
       field: 'cantidad', 
       title: 'Cant. Actual', 
       width: '200px' 
      }, 
      { 
       field: 'nuevaCantidad', 
       title: 'Cantidad' 
      }, 
      { 
       field: 'bodega', 
       title: 'Bodega' 
      }, 
      { 
       field: 'estanteria', 
       title: 'Estanter\u00EDa' 
      }, 
      { 
       field: 'seccion', 
       title: 'Secci\u00F3n' 
      }, 
      { 
       field: 'estanteriaID', 
       title: 'Estanter\u00EDa' 
      }, 
      { 
       field: 'seccionID', 
       title: 'Secci\u00F3n' 
      } 
      ] 
      }); 

在我的servlet我得到的參數像我平時所做的那樣:

request.getSession().setAttribute("codigoProducto", request.getParameter("codigoProducto")); 
request.getSession().setAttribute("bodegaID", request.getParameter("bodegaID")); 

該servlet正在執行,但當我嘗試使用參數,他們是空的,任何人都可以幫助找出我做錯了什麼。

回答

2

您可以將contentType選項設置爲application/x-www-form-urlencoded,因爲默認值是application/json

$tabla.bootstrapTable({ 
    method: 'post', 
    contentType: 'application/x-www-form-urlencoded', 
    ... 
}); 

這裏有一個相關的問題:https://github.com/wenzhixin/bootstrap-table/issues/918