Search code examples
jspspring-mvchibernate-validator

Validation message don't show single quote


I am testing Spring:MVC validation tutorial. I used hibernate validator for bean validation as

@Min(value = 16, message = "Under 16 can't allow here.")
@Max(value = 100, message = "You are too old.")
private int age;

At my JSP file

        <div class="form-group">
            <label class="control-label col-md-2 col-sm-2 col-md-offset-2">Age : </label>
            <div class="col-md-5 col-sm-5">
                <form:input path="age" class="form-control" cssStyle="width:50px" />
                <form:errors path="age" class="text-danger" />
            </div>              
        </div>  

When I fill up value less than 16 , validation error message does not include single-quote('). Check below screen shoot.

enter image description here

I am not sure which is the error , due to JSP or Hibernate or Spring MVC. How can I solve to show single quote ?


Solution

  • To use ' you need to escape it using '. So your error message should be like "Under 16 can''t allow here."

    Thymeleaf single quote in validation error message