简体   繁体   中英

Spring MVC : form:errors tag

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>

Use the <spring:hasBindErrors name="myFormBean"> tag, and inspect the page-scope errors bean.

Reference doc link

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM