queryParams引导程序表

时间:2015-10-19 09:45:29

标签: bootstrap-table

我正在这样的div中创建我的表:

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,但是当我尝试使用它们为null的参数时,任何人都可以帮助找出我做错了什么。

1 个答案:

答案 0 :(得分: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

相关问题