日期:2014-05-17 浏览次数:20661 次
private String JsonString;
public String getJsonString() {
return JsonString;
}
public void setJsonString(String jsonString) {
JsonString = jsonString;
}
下面是方法中的代码:
JSONArray jsonArray = JSONArray.fromObject(list_dir);
this.JsonString = jsonArray.toString();
<package name="test.action" extends="json-default" namespace="/sm">
<action name="scanPointPath" class="smAction" method="scanPointPath" >
<result name="success" type="json">
<param name="includeProperties">JsonString</param>
</result>
</action>
$.ajax( {
type : "POST",
url : "scanPointPath.action",
dataType:"json",
data : {
"postValue":leavePath
},
aysnc : false,
success : function(data) {
alert("dddd"+data); },
error : function() {
alert("cuowu");
}
});
success : function(data) {
alert("dddd"+data.constructor);//这里可以输出你返回的json的类型
},
var arr = ["xxxxxx","yyyyy"];
for(var i = 0, j = arr.length; i<j; i++){
alert(arr[i]);
}
<action name="scanPointPath" class="smAction" method="scanPointPath" >
<!-- 对于返回json 的action,我这里从来不写东西-->
</action>