1. POJO
public class Classtime {
private Byte id;
private String cno;
private String ctime;
2. JS
var param = {};
for(var i = 0; i < 12;i++) {
var id = i + 1;
var val = $("#" +id).val();
if (val.length == 0) {
alert("存在未录入的上课时间.");
return false;
}
param["classTimes[" + i + "].id"] = id;
param["classTimes[" + i + "].cno"] = id;
param["classTimes[" + i + "].ctime"] = val;
}
3. Ajax
jQuery.ajax( {
async : false,
cache : false,
type : 'POST',
dataType : "json",
url : root + "/e-school/paramset_saveOrupdateClassTime.action",
data : param,
error : function() {
alert("请求失败.");
},
success : function(data) {
if (data == null) {
alert("保存成功.");
} else if (data.errorMsg!=null) {
alert(data.errorMsg);
}
}
});
4. Action
private List classTimes = new ArrayList();
/**
* @return the classTimes
*/
public List getClassTimes() {
return classTimes;
}
/**
* @param classTimes
* the classTimes to set
*/
public void setClassTimes(List classTimes) {
this.classTimes = classTimes;
}