I am unable to run the struts2 application with json. i want to display json in client side page.i m building json object in action class.any advice is accetable.
<s:div id="my_result" >
<s:property value="jsonData" /></s:div><s:form action="giveMeJsonData" theme="simple"><sj:submit targets="my_result" value="Example" /></s:form>
<------ end of jsp client page--->
<package name="TestJson" extends="json-default"><action name="giveMeJsonData" class="test.testAction" method="myFunction">
<result type="json"><param name="root">jsonData</param></result> </action> </package>
<----------------end of struts.xml------------------>
public LinkedHashMap<String, String> getJsonData() { return jsonData; }
public void setJsonData(LinkedHashMap<String, String> jsonData) { this.jsonData = jsonData; }
public String execute() throws Exception {
return SUCCESS;
}
public String myFunction() {
jsonData = new LinkedHashMap<String, String>();
jsonData.put("My name is", "marco");
return SUCCESS;
}