2
我正在使用spring 3.1和annotations開發應用程序。spring註釋錯誤找不到類型驗證器:java.lang.Double
我寫型號,如下
package servlet.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.validator.constraints.NotEmpty;
@Entity
@Table(name="products")
public class Product {
@Id
@GeneratedValue
private Integer product_id;
@NotEmpty(message = "Category should not be blank.")
private String cat_id;
@NotEmpty(message = "Name should not be blank.")
private String product_name;
private String specification;
@NotEmpty(message = "Purchase Price should not be blank.")
private double purchase_price;
@NotEmpty(message = "Sales Price should not be blank.")
private double sales_price;
@NotEmpty(message = "Stock should not be blank.")
private double stock;
@NotEmpty(message = "Status should not be blank.")
private String status;
@Column(name="product_id")
public Integer getProduct_id() {
return product_id;
}
public void setProduct_id(Integer product_id) {
this.product_id = product_id;
}
@Column(name="cat_id")
public String getCat_id() {
return cat_id;
}
public void setCat_id(String cat_id) {
this.cat_id = cat_id;
}
@Column(name="product_name")
public String getProduct_name() {
return product_name;
}
public void setProduct_name(String product_name) {
this.product_name = product_name;
}
@Column(name="specification")
public String getSpecification() {
return specification;
}
public void setSpecification(String specification) {
this.specification = specification;
}
@Column(name="purchase_price")
public double getPurchase_price() {
return purchase_price;
}
public void setPurchase_price(double purchase_price) {
this.purchase_price = purchase_price;
}
@Column(name="sales_price")
public double getSales_price() {
return sales_price;
}
public void setSales_price(double sales_price) {
this.sales_price = sales_price;
}
@Column(name="stock")
public double getStock() {
return stock;
}
public void setStock(double stock) {
this.stock = stock;
}
@Column(name="status")
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
同時提交我收到請求處理失敗的形式;嵌套異常是javax.validation.UnexpectedTypeException:找不到可用於類型的驗證程序:java.lang.Double
我用過它。但給新的錯誤。 Property purchase_price引發異常;嵌套異常是java.lang.IllegalArgumentException –