Struts2 jQuery DataTable 1.10多维Http参数 [英] Struts2 jQuery DataTable 1.10 Mutidimensional Http Parameters
问题描述
columns [1] [data]
我的struts动作中有一个名为columns的列表,它包含一个带有data属性的对象。当动作触发时,任何东西都不会进入列列表。我知道通常我会发送一个这样的参数:
列[1] .data
我挖掘到DataTables代码,发现它正在使用 jQuery.param
序列化由DataTables创建的JS对象。我已经尝试将ajax请求的传统参数设置为 true
,但是我得到 [object + Object]
有人可以告诉我是否有办法执行以下操作之一:
- 获取Struts2以处理此参数符号
- 更改jQuery序列化这些参数名称的方式
DataTables中有一个选项可以还原回它发送的旧参数,但是看起来这可能不会永远存在,我宁愿使用新的参数结构
以下格式的参数 columns [1] ['data']
(注意'
围绕数据
)实际上可以与Struts2一起工作。因此,您可以尝试调整序列化过程以将单引号添加到参数。
但是,您似乎可以发送来自DataTables的JSON字符串,这是更好的做事方式,而不是搞乱参数序列化。
还有 struts2-json-plugin
,可以从JSON字符串填充动作变量。
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]
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
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:
- Get Struts2 to deal with this parameter notation
- Change the way jQuery serializes these parameter names
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.
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.
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屋!