我正在休息呼叫春天控制器,它失敗,錯誤的請求(400原因,原來的問題Spring Controller 400 (Bad Request))春季控制器REST調用失敗
我最初的REST調用的參數是要打通:
categoty: "Game"
itemDescription: "adas"
itemDiscount: 1
itemName: "asdas"
itemPrice: 1
itemQuantity: 1
這失敗了,但是當我改變的參數如下,它的工作:
categoty: "Game"
description: "test1"
discount: 10
name: "Test"
price: 10
quantity: 10
我的持久性POJO類是:
import javax.persistence.*;
@Entity
@Table(name= "Item")
public class Item {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private int id;
private String itemName,itemDescription,categoty;
private double itemPrice;
private float itemDiscount;
private int itemQuantity;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getQuantity() {
return itemQuantity;
}
public void setQuantity(int quantity) {
this.itemQuantity = quantity;
}
public float getDiscount() {
return itemDiscount;
}
public void setDiscount(float discount) {
this.itemDiscount = discount;
}
public double getPrice() {
return itemPrice;
}
public void setPrice(double price) {
this.itemPrice = price;
}
public String getName() {
return itemName;
}
public void setName(String iName) {
this.itemName = iName;
}
public String getDescription() {
return itemDescription;
}
public void setDescription(String desc) {
this.itemDescription = desc;
}
public String getcategoty() {
return categoty;
}
public void setcategoty(String cat) {
this.categoty = cat;
}
}
有人可以幫助我理解爲什麼第二類參數工作,而第一個沒有(理想的第一個是一對一的映射到持久性類的屬性) ?
它一個錯字?我和吸氣者和接受者一樣t從所有變量中刪除前綴名稱,查看這些示例[示例1](https://www.jetbrains.com/idea/help/generating-getters-and-setters.html)和[示例2](http:///stackoverflow.com/questions/14143528/eclipse-generate-getter-setter-for-domain-objects-and-classmembers-with-m-suff) – 2015-03-08 22:32:50
它使用getters/setters。 – ema 2015-03-08 22:34:32