我正在尝试创建一个RestFul dao Web服务。非常简单地调用make一个HTTP请求CRUD数据。所有似乎都工作(我使用curl创建HTTP请求),除了在控制器方法中我没有得到绑定到pojo的json数据。这是控制器代码:
@PostMapping("/deleteJonTblGet")
public ResponseEntity getDeleteJonTbl(@RequestBody DeleteJonTblId deleteJonTblId)
{
System.out.println("TEST:");
System.out.println(deleteJonTblId.getDJon());
DeleteJonTbl deleteJonTbl = deleteJobTblDao.findById(1);
if (deleteJonTbl == null)
{
return new ResponseEntity("No Customer found for ID ", HttpStatus.NOT_FOUND);
}
return new ResponseEntity(deleteJonTbl, HttpStatus.OK);
}
这是POJO: 公共类DeleteJonTblId实现java.io.Serializable {
private String DJon;
private String DReturn;
private Integer DCtr;
private String DRecdat;
private String DRectime;
public DeleteJonTblId()
{
}
public DeleteJonTblId(String DJon, String DReturn, Integer DCtr, String DRecdat, String DRectime)
{
this.DJon = DJon;
this.DReturn = DReturn;
this.DCtr = DCtr;
this.DRecdat = DRecdat;
this.DRectime = DRectime;
}
@Column(name = "D_JON", length = 12)
public String getDJon()
{
return this.DJon;
}
public void setDJon(String DJon)
{
this.DJon = DJon;
}
@Column(name = "D_RETURN", length = 2)
public String getDReturn()
{
return this.DReturn;
}
public void setDReturn(String DReturn)
{
this.DReturn = DReturn;
}
@Column(name = "D_CTR", precision = 7, scale = 0)
public Integer getDCtr()
{
return this.DCtr;
}
public void setDCtr(Integer DCtr)
{
this.DCtr = DCtr;
}
@Column(name = "D_RECDAT", length = 8)
public String getDRecdat()
{
return this.DRecdat;
}
public void setDRecdat(String DRecdat)
{
this.DRecdat = DRecdat;
}
@Column(name = "D_RECTIME", length = 6)
public String getDRectime()
{
return this.DRectime;
}
public void setDRectime(String DRectime)
{
this.DRectime = DRectime;
}
public boolean equals(Object other)
{
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof DeleteJonTblId))
return false;
DeleteJonTblId castOther = (DeleteJonTblId) other;
return ((this.getDJon() == castOther.getDJon())
|| (this.getDJon() != null && castOther.getDJon() != null && this.getDJon().equals(castOther.getDJon())))
&& ((this.getDReturn() == castOther.getDReturn()) || (this.getDReturn() != null
&& castOther.getDReturn() != null && this.getDReturn().equals(castOther.getDReturn())))
&& ((this.getDCtr() == castOther.getDCtr()) || (this.getDCtr() != null && castOther.getDCtr() != null
&& this.getDCtr().equals(castOther.getDCtr())))
&& ((this.getDRecdat() == castOther.getDRecdat()) || (this.getDRecdat() != null
&& castOther.getDRecdat() != null && this.getDRecdat().equals(castOther.getDRecdat())))
&& ((this.getDRectime() == castOther.getDRectime()) || (this.getDRectime() != null
&& castOther.getDRectime() != null && this.getDRectime().equals(castOther.getDRectime())));
}
public int hashCode()
{
int result = 17;
result = 37 * result + (getDJon() == null ? 0 : this.getDJon().hashCode());
result = 37 * result + (getDReturn() == null ? 0 : this.getDReturn().hashCode());
result = 37 * result + (getDCtr() == null ? 0 : this.getDCtr().hashCode());
result = 37 * result + (getDRecdat() == null ? 0 : this.getDRecdat().hashCode());
result = 37 * result + (getDRectime() == null ? 0 : this.getDRectime().hashCode());
return result;
}
}
这是卷曲:
curl --libcurl C:\ Development \ test.log -i -X POST -H“Content-Type:application / json”-d“{\”DJon \“:\”a \“,\”DReturn \“:\”a \“,\”DCtr \“:1,\”DRecdat \“:\”a \“,\”DRectime \“:\”a \“}”http://localhost:8080/taaDaoWS/deleteJonTblGet
执行controller方法但deleteJonTblId对象具有所有空值。任何帮助将不胜感激。
答案 0 :(得分:0)
有趣:我将json列名称更改为小写并开始工作。