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

查看:24
本文介绍了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:

columns[1][data]

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

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.因此,您可以尝试调整序列化过程,为参数添加额外单引号.

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天全站免登陆