Announcement Announcement Module
Collapse
No announcement yet.
Displaying global error message with arguments resolved Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Displaying global error message with arguments resolved

    Hello,

    I just began learning and using Spring and this is my first post to the forums.

    In the Validator class, I have registered a global error:
    Code:
    errors.reject("error.required.fields.blank", new Object[]{new String("My Arguments")}, "Required fields cannot be blank");
    In the errors.properties file, I have an entry for the above error code:
    Code:
    error.required.fields.blank=Required Field(s) {0} cannot be blank
    In the JSP, I am trying to display the error message using:
    Code:
    <spring:hasBindErrors name="user">
            <c:forEach items="${errors.allErrors}" var="err">
                    <spring:message code="${err.code}" text="${err.defaultMessage}"/><br>
            </c:forEach>
    </spring:hasBindErrors>
    But the error message is displayed as
    Required Field(s) {0} cannot be blank
    I would like the arguments in the error message to be substituted by the values I provide in the Validator class.

    If I tie the same error message to a form field using error.rejectValue() and display it using <form:errors> tag in the JSP, it gets displayed fine.

    Any help is appreciated.

    Thanks,
    Anand

  • #2
    Can somebody please help?

    Comment

    Working...
    X