我使用mvc jersey服务器,我想发送一些包含两个键的json对象:1。propertyComponent对象的task 2.propertyComponent-jsonArray。 这是我的JsonObject请求:
{"task":{"apartment":4,"actionTypeId":1,"comments":"","crDate":1467204343000,"crUser":"CRM","crmTaskId":"20160600056\/1","moduleId":1,"nActive":null,"nAppro":3,"nApproDetails":null,"nApproFdate":null,"nContar":3,"nContarDetails":null,"nDivided":3,"nDividedDetails":null,"nElectricity":3,"nEmpty":3,"nEmptyDetails":null,"nEmptyFdate":null,"nFloor":3,"nFloorFdate":null,"nFnType":3,"nFnUser":"","nKBusy":3,"nKBusyDetails":null,"nKItem":3,"nKItemDetails":null,"nKType":null,"nKTypeDetails":null,"nKUse":3,"nKUseDetails":null,"nMeasure":3,"nMeasureDetails":null,"property":{"aSugNecesDetails":"מחסנים לשיווק","aZhuiPhisi":1111,"complot1":null,"complot2":null,"complot3":null,"latitude":32.0721694,"longitude":34.8780671,"meshalemName":"יוסי כהן","misparNecsiMishne":null,"rashutId":248,"taskId":2264,"ktovetNeces":"האדמור איפרגן 29\/4 ג","aezorMisim":0,"agodelNeces":100,"agushHelkaTat":638825614,"akarkaNeto":0,"amhutHaesek":0,"amisparHadarim":null,"amisparKomot":null,"asemelRehov":1314,"asemelYshuv":null,"ashemBaal":"נסיון שירן ניסיו ונ","ashetachBnia":0,"ashetachHelka":0,"asugNeces":14,"azehutBaal":87654323,"azhuiMeshalem":87654323},"nNonItem":null,"nNonItemDetails":null,"nOverhaul":3,"nOverhaulDetails":null,"nOverhaulFdate":null,"nOwnerp":3,"nPlumbing":3,"nPopulated":3,"nPopulatedFdate":null,"nRoof":3,"nSize":3,"nSubn":3,"nSubnDetails":null,"nToN":3,"nToNDetails":null,"nUsage":"1","nUsageDetails":null,"nWater":3,"rashutId":248,"taskDuedate":1467204343000,"taskDuedateP":1467204343000,"taskId":2264,"taskStatus":2,"taskType":2,"userId":"040634461","wPlanId":999999,"actionTypeName":"החלפת משלמים","workPlanName":"ללא שיוך","crmIncidentNum":null,"meetTime":null,"hour":null,"crmSpecifications":null,"executionDate":1494760023635,"crmReqName":"יוסי כהן","crmReqMobile":"054-5555555","crmReqHPhone":"035353855","crmReqWPhone":null,"address":null,"draft_ind":true,"image_required":true,"subPropertyInd":false,"minute":null,"userName":"עידו גפני","distance":31565},"propertyComponents":[{"taskId":2264,"rashutId":139,"cmpZihuyPhizi":"1111","cmpCode":"999","cmpName":"אחר","cmpLenght":20,"cmpWidth":10,"cmpTotal":200,"isRemoved":false},{"taskId":2264,"rashutId":139,"cmpZihuyPhizi":"1111","cmpCode":"999","cmpName":"אחר","cmpLenght":30,"cmpWidth":20,"cmpTotal":600,"isRemoved":false},{"taskId":2264,"rashutId":139,"cmpZihuyPhizi":"1111","cmpCode":"999","cmpName":"אחר","cmpLenght":40,"cmpWidth":30,"cmpTotal":1200,"isRemoved":false}]}
在我的服务器端,我创建了一些请求实体对象:
@XmlRootElement
@JsonIgnoreProperties(ignoreUnknown = true)
public class taskWithPropertyComponentResponse {
private List<propertyComponent> propertyComponents;
private Task task;
@JsonProperty("propertyComponents")
public List<propertyComponent> getPropertyComponents() {
return propertyComponents;
}
public void setPropertyComponents(List<propertyComponent> propertyComponents) {
this.propertyComponents = propertyComponents;
}
@JsonProperty("task")
public Task getTask() {
return task;
}
public void setTask(Task task) {
this.task = task;
}
}
这是 propertyComponent 模型:
String id;
String taskId;
String rashutId;
String cmpZihuyPhizi;
String cmpCode;
String cmpName;
double cmpLenght;
double cmpWidth;
double cmpTotal;
boolean isRemoved;
当我用这个json发送客户端请求时,我得到401错误, 我该怎么做才能解决这个问题? 如何使用jersey将jsonArray发送到服务器?
谢谢!