[英]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. 如何检查JSP页面上的特定错误,并仅在出现该错误时显示它。
For example I would like to check whether the following error exists using <c:if>
tag and only then render it as HTML. 例如,我想使用<c:if>
标记检查是否存在以下错误,然后将其呈现为HTML。
<form:errors path="transactionType" cssClass="error"></form:errors>
Use the <spring:hasBindErrors name="myFormBean">
tag, and inspect the page-scope errors bean. 使用<spring:hasBindErrors name="myFormBean">
标记,并检查页面范围错误Bean。
You already get this functionality with the <form:errors>
tag. 您已经通过<form:errors>
标记获得了此功能。 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. 它仅在存在相应错误时(基于path
属性)呈现其内容,因此类似于使用<c:if>
首先检查错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.