1 回答
TA贡献1864条经验 获得超2个赞
在javascript结尾的字体中:
function onSubmit(){
var items = $("#jsGrid").jsGrid("option", "data");//$("#jsGrid") must match <div id="jsGrid"></div>
var json = JSON.stringify(items);
document.form1.json.value=json;
}
<form name="form1" method="post" action="MyJavaBackend">
<div id="jsGrid"></div>
<input type="hidden" name="json" >
<Input type="button" onClick="onSubmit();">
</form>
在后端Java中:
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
.....
String json_data = request.getParameter("json");
JSONArray jsonArray = new JSONArray(json_data);
for(int i=0;i<jsonArray.length();i++) {
JSONObject jsonObject=jsonArray.getJSONObject(i);
String name=jsonObject.getString("Name");
String age=jsonObject.getString("Age");
}
....
添加回答
举报