Struts 2 jquery sj: select und json result
Ich verwende Struts 2 JQuery Plugin Select Component.
Die Aktion ist:
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;
}
}
The jsp ist
<sj:select list="samples" />
Das Problem ist, dass das json-Plugin alle Eigenschaften in Aktion serialisiert anotherList
, anString
etc ...), wie unten
{
"samples": {
"0": {"property":"a"},
"1": {"property":"b"},
"2": {"property":"c"}
},
"anString": "hello",
"anotherList": {
"0": {"prop1":"a","prop2":"b"},
"1": {"prop1":"c","prop2":"d"}
}
}
Wenn ich den json ändereroot
Parameter zusamples
, dann ist diejs:select
funktioniert nicht, da keine Liste mit dem Namen @ gefunden werden kansamples
im zurückgegebenen json. Der zurückgegebene JSON lautet:
{
"0": {"property":"a"},
"1": {"property":"b"},
"2": {"property":"c"}
}
Kann das behoben werden?! Kann ich das struts 2 json Plugin so konfigurieren, dass es @ generier
{
"samples": {
"0": {"property":"a"},
"1": {"property":"b"},
"2": {"property":"c"}
}
}
Oder gibt es einen Grund, warum Struts 2-JQuery-Plug-In das einfache JSON-Array akzeptiert?