$.ajax({
url:'${pageContext.request.contextPath}/backend/system/userRelative/add',
type: 'POST',
data: {
id:$("#id").val(),
cardNo:userCardNoAdd.val(),
userName:userNameAdd.val(),
companyName:companyNameAdd.val(),
departmentName:departmentNameAdd.val(),
userRelatives.relativeName:relativeNameAdd.val(),
userRelatives.relativeType:relativeTypeAdd.val(),
userRelatives.relativeCardNo:relativeCardNoAdd.val()},
error: function(XMLHttpRequest, textStatus, errorThrown){alert('error' + textStatus + "/" + errorThrown);},
success: function(data){
if(data=='success') {
alert('success');
$("#userRelativeDIV").dialog("close");
} else {
alert('fail');
}
}
});
* User 和 UserRelative 是一对多的关系;现在我想保存一个实体用户;但我有一个问题;如何使用 jquery.ajax 将实体用户发送到 Spring Controller;如何通过 jquery.ajax 将值放入 Set *
public class User implements java.io.Serializable {
private long id;
private String userName;
private Set<UserRelative> userRelatives = new HashSet<UserRelative>(0);
......}
公共类 UserRelative 实现 java.io.Serializable {
private long id;
private User user;
private String relativeName;
private String relativeType;
private String cardNo;
...}