如何通过jquery.ajax </userrelative>将值放入Set <userrelative>中

时间:2013-09-11 00:54:25

标签: jquery ajax

$.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);
......}

public class UserRelative实现了java.io.Serializable {

private long id;
 private User user;
 private String relativeName;
 private String relativeType;
 private String cardNo; 
...}

1 个答案:

答案 0 :(得分:0)

我不是专家,但如果我是你,我只会使用AJAX发布与用户属性相对应的值。在Controller中,构造User实体并保存到Model。