使用hibernate進行數據校驗那些事

 javax.validation.UnexpectedTypeException: No validator could be found for type: java.lang.Integer

錯誤來源如下

@NotEmpty(message="接收人類型不能夠爲空")
    public Integer getRecievetype() {
        return this.recievetype;
    }

正確的寫法應爲

@NotNull(message="接收人類型不能夠爲空")
    public Integer getRecievetype() {
        return this.recievetype;
    }

在網上找了一下,找到一個博文,覺得可以記錄下來,如下:

@NotNull、@NotEmpty、@NotBlank 三者的區別

@NotEmpty 用在集合類上面
@NotBlank 用在String上面
@NotNull    用在基本類型上
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章