aditya
aditya

Reputation: 495

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 message.properties file

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

help me please

Upvotes: 1

Views: 519

Answers (1)

Javi
Javi

Reputation: 19769

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.

Upvotes: 6

Related Questions