Reputation: 263
How can I check for a particular error on a JSP page and only show it when it is present.
For example I would like to check whether the following error exists using <c:if>
tag and only then render it as HTML.
<form:errors path="transactionType" cssClass="error"></form:errors>
Upvotes: 0
Views: 8375
Reputation: 35169
Use the <spring:hasBindErrors name="myFormBean">
tag, and inspect the page-scope errors bean.
Upvotes: 6
Reputation: 13473
You already get this functionality with the <form:errors>
tag. It only renders its contents when there is a corresponding error (based on the path
attribute), so it is analogous to using a <c:if>
to first check for an error.
Upvotes: 5