这是我的要求类
public class TestRequest implements Serializable {
private static final long serialVersionUID = 1L;
private String vendorID = null;
private String transactionID = null;
@JsonProperty("TESTAction")
private String TESTAction = null;
public String getVendorID() {
return vendorID;
}
public void setVendorID(String vendorID) {
this.vendorID = vendorID;
}
public String getTransactionID() {
return transactionID;
}
public void setTransactionID(String transactionID) {
this.transactionID = transactionID;
}
public String getTESTAction() {
return TESTAction;
}
public void setTESTAction(String TESTAction) {
TESTAction = TESTAction;
}
@Override
public String toString() {
return "TestStatus [vendorID=" + vendorID + ", transactionID=" + transactionID + ", s TESTAction=" + TESTAction + "]";
}
}
这是我的服务类
HttpEntity<TestRequest > requestEntity = new HttpEntity<>(request, headers);
try {
LOG.info("Calling REST: " + restUrl);
responseEntity = restTemplate.postForEntity(restUrl, requestEntity, TestResponseResponse.class);
} catch (Exception e) {
LOG.error("Exception in sending data: " + request);
LOG.error("Exception in sending data to ESL" + e);
throw new TestRestException("Exception while calling rest service", e);
}
其余调用正常工作正常,但问题是请求对象中的第三个参数被发送两次,例如:
{
"vendorID": "testvendor",
"transactionID" : "testtrans",
"TESTAction": "test action",
"testaction":"test action"
}
最后一个参数在所有小字符中发送两次
答案 0 :(得分:0)
通过为getter和setter使用正确的java命名约定解决了这个问题。
为什么Spring与命名紧密结合仍然存在 但是约定。