Struts2 jQuery DataTable 1.10 多维 Http 参数 [英] Struts2 jQuery DataTable 1.10 Mutidimensional Http Parameters

查看:30
本文介绍了Struts2 jQuery DataTable 1.10 多维 Http 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 DataTables 1.9 的 Struts 2 应用程序.我现在正在尝试将其转换为 DataTables 1.10,它改变了将 HTTP 参数发送到服务器的方式.我现在正在尝试处理如下所示的 HTTP 参数:

I have a Struts 2 application that was using DataTables 1.9. I am now trying to convert it over to DataTables 1.10 which changed the way it sends the HTTP Parameters to the server. I am now trying to deal with a HTTP Parameter that looks like this:

列[1][数据]

我的 struts 动作中有一个名为columns"的列表,其中包含一个具有data"属性的对象.当动作触发时,没有任何东西进入列列表.我知道通常我会使用以下方式发送这样的参数:

I have a List in my struts action called "columns" which contains an object with a "data" property. Nothing gets pushing into the columns list when the action fires. I know that normally I would send a parameter like this using:

columns[1].data

我研究了DataTables的代码,发现它是使用jQuery.param来序列化DataTables创建的JS对象.我曾尝试将 ajax 请求上的传统"参数设置为 true,但随后我得到 [object+Object] 作为参数值.

I dug into the DataTables code and found out that it is using the jQuery.param to serialize the JS object created by DataTables. I have tried to set the "traditional" parameter on the ajax request to true, but then I get [object+Object] for the parameter value.

有人可以告诉我是否有办法执行以下操作之一:

Can someone please tell me if there is a way to do one of the following:

  • 获取 Struts2 来处理这个参数表示法
  • 改变 jQuery 序列化这些参数名称的方式

DataTables 中有一个选项可以恢复到它发送的旧参数,但似乎这可能不会永远存在,我更愿意让它与新的参数结构一起使用.

There is an option in DataTables to revert back to the old parameters it sent, but it seems like this may not be around forever and I would prefer to get it working with the new parameter structure.

推荐答案

参数格式如下columns[1]['data'](注意'code>data) 实际上可以与 Struts2 一起使用.因此,您可以尝试调整序列化过程以在参数中添加 extra 单引号.

Parameters in following format columns[1]['data'] (note the ' around data) would actually work with Struts2. So you can try to tweak serialization process to add extra single quotes to parameters.

但您似乎可以从 DataTables 发送 JSON 字符串,这样更好做事的方式,而不是弄乱参数序列化.还有 struts2-json-plugin它可以从 JSON 字符串中填充动作变量.

BUT it seems that you can send JSON string from DataTables, which is a better way of doing things rather than messing with parameter serialization. And there is struts2-json-plugin which can populate action variables from the JSON string.

这篇关于Struts2 jQuery DataTable 1.10 多维 Http 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆