1

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

2
  • what exactly does it say? what's the message? Is there any stacktrace. Which version of hibernate validator (or which jsr 303 provider) ? Commented Dec 10, 2010 at 8:07
  • ok tell me how i validate an integer value in spring which is inputted from jsp page. Commented Dec 10, 2010 at 8:30

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.