Search code examples
springspring-mvcspring-annotations

Spring validation @AssertTrue


How do I display on a view jsp validation error message that occurs as a result of @AssertTrue annotation? It isn't tied to a specific field, but I am using it to validate a combination of fields. If I use <form:errors path="*"/> that will display all the errors for that form?


Solution

  • Declaring a boolean property is what seems to work for this. So if there is:

    @AssertTrue
    public boolean isConditionTrue() {
       ...
       ...
    }
    

    then declaring a property like:

    private boolean conditionTrue;
    

    works.