I have some problems with hibernate validations with Spring. I did everything as explained in an online tutorial, but it’s not working and I just go to the next page without validation error. Controller: customer-form.jsp So, there are no errors in BindingResult when I have an empty field for lastName. What am i doing wrong? Answer Add hibernate-validator in your
Tag: validation
Java Regex First Name Validation
I understand that validating the first name field is highly controversial due to the fact that there are so many different possibilities. However, I am just learning regex and in an effort to help grasp the concept, I have designed some simple validations to create just try to make sure I am able to make the code do exactly what
validation with double value in Spring
I want to check score which have value: 0.00 <= value<= 10.00 I used: -Model(Score): -messages.properties: -servlet-context.xml: But the value = 10.01 has passed the check. Please help me. Answer I resolve my proplem with: Thank you lots @ Kayaman ,@hyness
Unique regex for first name and last name
I have a single input where users should enter name and surname. The problem is i need to use checking regEx. There’s a list of a requirements: The name should start from Capital Letter (not space) There can’t be space stacks It’s obligate to support these Name and Surname (all people are able to write theirs first/name). Example: And the
spring combine two validation annotations in one
I’m using Spring+Hibernate+Spring-MVC. I want to define a custom constraint combining two other predefined validation annotations: @NotNull @Size like this: and I want to use this annotation in my form models. UserController.java But it does not work. It accepts the less than 4 character passwords. How can I solve this problem? Answer This is a bit late, but technique of
How does the validate() method in Struts 2 get the result “input”?
In Struts 2, “input” is returned when a check fails in the validate() method. I then map <result name=”input”> in struts.xml for the appropriate page. I am just wondering how it gets the “input”, which is a String when the validate() method itself returns void? I would like to understand this concept. Answer The validate() method itself returns nothing (void).
Manually call Spring Annotation Validation
I’m doing a lot of our validation with Hibernate and Spring Annotations like so: And then in the controller it’s called in the arguments: But I would like to decide the group used based on some logic in the controller method. Is there a way to call validation manually? Something like result = account.validate(Account.Step1.class)? I am aware of creating your
Save drop-down list value to database in Struts 2 with Hibernate
I want to save the selected value of drop-down list into the database. First index.jsp is loaded. From index.jsp, we can go to register.jsp when we click register URL of index.jsp. struts.xml: index.jsp: register.jsp: Action class is: the drop down list is actually only one of the form fields. there are other fields also in the form. All values other
How to pass an action name using hyperlink in Struts 2?
I have a hyperlink named “Click for new User”. Once I click the link, I got NullPointerException instead of opening RegisterPage.jsp page. I post my code here, I can’t find my mistake index.jsp: struts.xml: Login.java(Action Class): Exception: Answer When you click on hyperlink you don’t supply the request URL with parameters username and password (the parameters aren’t set by the
Difference between @size(max = value ) and @min(value) and @max(value)
I want to do some domain validation. In my object I have one integer. Now my question is: if I write and If it’s an integer which one is proper for domain validation? Can anybody explain me what is the difference between them? Thanks. Answer @Min and @Max are used for validating numeric fields which could be String(representing number), int,