2014-07-22 3 views
2

스프링 3.1과 주석을 사용하여 어플리케이션을 개발 중입니다. 내가 요청 처리에 실패 얻고 양식을 제출하면서스프링 주석 에러 타입에 대한 밸리데이터를 찾을 수 없습니다 : 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

답변

4

Anotation @NotEmpty 지원 유형 : 문자열, 컬렉션, 맵 및 배열. 당신은 @NotNull anotation을 시도 할 수 있습니다. 또는 다른 anotation

이것을 참조하십시오 Validation step by step

+0

나는 그것을 사용했습니다. 그러나 새로운 오류를 제공합니다. purchase_price 속성에서 예외가 발생했습니다. 상자의 예외는 java.lang.IllegalArgumentException입니다. –

관련 문제