带struts2的jTable jquery
我正在用Struts2开发一个jquery Jtable,因此当我想添加新记录或更新现有记录时,我在弹出窗口中输入新值,struts操作不会恢复这些值,新记录会添加所有空值。 这是我的java方法:带struts2的jTable jquery,jquery,struts2,row,add,jquery-jtable,Jquery,Struts2,Row,Add,Jquery Jtable,我正在用Struts2开发一个jquery Jtable,因此当我想添加新记录或更新现有记录时,我在弹出窗口中输入新值,struts操作不会恢复这些值,新记录会添加所有空值。 这是我的java方法: private String nom,identifiant; private String prenom; private String email; // getter/setter... public String create() throws IOException { reco
private String nom,identifiant;
private String prenom;
private String email;
// getter/setter...
public String create() throws IOException {
record = new Student();
record.setNom(this.getNom());
record.setPrenom(this.getPrenom());
record.setEmail(this.getEmail());
record.setIdentifiant(getIdentifiant());
try {
// Create new record
dao.ajout(record);
result = "OK";
} catch (Exception e) {
result = "ERROR";
message = e.getMessage();
System.err.println(e.getMessage());
}
return Action.SUCCESS;
}
这里是jquery代码:
$(document).ready(function () {
$('#StudentTableContainer').jtable({
title: 'Liste des agents pharmaciens',
paging : true, //Enable paging
pageSize : 3, //Set page size (default: 10)
actions: {
listAction : 'afficheStudent',
createAction : 'createAction',
updateAction : 'updateAction',
deleteAction : 'deleteAction'
},
fields: {
id: {
title:'id',
key: true,
list: true,
},
identifiant: {
title: 'Identifiant',
width: '20%',
edit:true
},
nom: {
title: 'Nom',
width: '20%',
edit:true
},
prenom: {
title: 'Prenom',
width: '30%',
edit:true,
create:true
},
email: {
title: 'Email',
width: '20%',
edit: true,
create:true
}
}
});
$('#StudentTableContainer').jtable('load');
});
一个错误是字段nom没有create:true选项
$(document).ready(function () {
$('#StudentTableContainer').jtable({
title: 'Liste des agents pharmaciens',
paging : true, //Enable paging
pageSize : 3, //Set page size (default: 10)
actions: {
listAction : 'afficheStudent',
createAction : 'createAction',
updateAction : 'updateAction',
deleteAction : 'deleteAction'
},
fields: {
id: {
title:'id',
key: true,
list: true,
},
identifiant: {
title: 'Identifiant',
width: '20%',
edit:true
},
nom: {
title: 'Nom',
width: '20%',
edit:true,
create: true //this is one error
},
prenom: {
title: 'Prenom',
width: '30%',
edit:true,
create:true
},
email: {
title: 'Email',
width: '20%',
edit: true,
create:true
}
}
});
$('#StudentTableContainer').jtable('load');
});
检查发送到服务器的内容。我检查了,但似乎无法将值从窗体恢复到actions类以便保存在数据库中打开浏览器中的开发工具,选择“网络”选项卡,查看发送到服务器的内容。如果这不能完全解决您的问题,我可以重新查看