大佬教程收集整理的这篇文章主要介绍了Struts 2 jQuery sj:select和json结果,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
您可以使用includePropertIEs
参数Json结果。例如
@Result(type="Json", params = {"includePropertIEs", "samples.*" })
多一个样本
@Result(type="Json", params = {"root", "samples", "wrapPrefix", "{\"samples\":", "wrapSuffix", "}"})
我正在使用struts 2 jquery插件选择组件。
动作是:
SampleAction {
private List<SampleVO> samples; //With setters and getters
private List<AnotherVO> anotherList; //With setters and getters
private String anString; //With setters and getters
@Action(value = "/loadSELEct",results = {
@Result(name = "success",type = "json")})
public String loadSomeSamples() {
samples = new ArrayList<SampleVO>();
//Put some object in samples.
return succesS;
}
}
JSP是
<sj:SELEct list="samples" />
问题是json插件将序列化所有实际使用中的属性(anotherList
,anString
等&Hellip;),如下所示
{
"samples": {
"0": {"property":"a"},"1": {"property":"b"},"2": {"property":"c"}
},"anString": "Hello","anotherList": {
"0": {"prop1":"a","prop2":"b"},"1": {"prop1":"c","prop2":"d"}
}
}
如果我将json root
参数更改为samples
,则js:SELEct
不会起作用,因为它找不到samples
在返回的json
中命名的任何列表。返回的json是:
{
"0": {"property":"a"},"2": {"property":"c"}
}
可以解决这个问题吗?有什么办法可以配置struts 2 json插件来生成
{
"samples": {
"0": {"property":"a"},"2": {"property":"c"}
}
}
还是有任何原因为什么struts 2 jquery插件接受简单的json数组
以上是大佬教程为你收集整理的Struts 2 jQuery sj:select和json结果全部内容,希望文章能够帮你解决Struts 2 jQuery sj:select和json结果所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。