开发者

error while using @Valid in spring mvc 3.0

here what i do in a model class

private Integer height;

@NotBlank
@Length(min = 2, max = 3)
public Integer getHeight() {
    return height;
}

public void setHeight(Integer height) {
    this.height = height;
}

but there is a validation error in the jsp page while running, it says that cannot validate the integer value.

in the 开发者_如何学JAVAmessage.properties file

NotBlank.modelClassName.height=Required in cm. Length.modelClassName.height=min {0} max (1). typeMismatch.modelClassName.height=numbers only.

help me please


Both annotations @NotBlank and @Length must be applied to an String attribute not to an Integer one, as it is stated in the links. Maybe you can use @NotNull, @Min or @Max that could be used for numbers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜