中的myController的方法是这样的客户端发送请求是语法不正确发送POST请求
@RequestMapping(value="/{processId}/dependents", method=RequestMethod.POST,consumes="application/json")
@ResponseBody
public Dependents postdependent(@ModelAttribute ProcessContext process,@RequestBody Dependent dependent) {
return process.getDependents().addDependent(dependent);
}
我得和完美的删除工作的时候。 但是,每当我做了一篇文章,我得到客户端发送的请求是语法不正确。 JSON的POST请求:
"{
'dependentId' : '1003',
'firstName' : 'Vishu',
'lastName' : 'poodari',
'birthDate' : '1970/04/15'
}"
请我用单引号尝试了所有组合,双引号,应有尽有。
我使用的休息壳做的操作。
请找我的依赖类
public class Dependent {
private String dependentId;
private String firstName;
private String lastName;
private String birthDate;
@JsonCreator
public Dependent(@JsonProperty("dependentId") String dependentId, @JsonProperty("firstName") String firstName, @JsonProperty("lastName")String lastName,
@JsonProperty("birthDate") String birthDate) {
this.dependentId = dependentId;
this.firstName = firstName;
this.lastName = lastName;
this.birthDate = birthDate;
}
public String getDependentId() {
return dependentId;
}
public void setDependentId(String dependentId) {
this.dependentId = dependentId;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getBirthDate() {
return birthDate;
}
public void setBirthDate(String birthDate) {
this.birthDate = birthDate;
}
}
向我们展示你的'Dependent'类。另外,将您的日志级别调试并检查日志。 –
已添加依赖类。 – Vishwa
您是否正在发送查询字符串,以便Spring可以生成'@ ModelAttribute'?你期望它是从哪里产生的? –