Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Validation 自定义表单:spring mvc验证的错误_Validation_Spring Mvc_Custom Error Pages - Fatal编程技术网

Validation 自定义表单:spring mvc验证的错误

Validation 自定义表单:spring mvc验证的错误,validation,spring-mvc,custom-error-pages,Validation,Spring Mvc,Custom Error Pages,我使用的是Spring3MVC,我只想按特定顺序显示错误消息 下面我添加的逻辑运行良好。但是,我想添加一个if语句来检查是否存在这样的错误。如果出现错误,我将添加“tr”块 <table cellpadding="0" > <c:forEach items="accountBean.nameSurname,accountBean.creditCart,accountBean.cvc" var="err" > <%--check error f

我使用的是Spring3MVC,我只想按特定顺序显示错误消息

下面我添加的逻辑运行良好。但是,我想添加一个if语句来检查是否存在这样的错误。如果出现错误,我将添加“tr”

<table cellpadding="0" >
      <c:forEach items="accountBean.nameSurname,accountBean.creditCart,accountBean.cvc" var="err" >
      <%--check error for controlling--%>                
      <tr>
        <td valign="top"><div class="attention"></div></td>
        <td valign="middle" align="left"><form:errors path="${err}"></form:errors> </td>
      </tr>
      </c:forEach>
</table>

这样的解决方案怎么样

<table cellpadding="0" cellspacing="0" border="0" align="center">
  <c:forEach items="nameSurname,creditCart,cvc,monthAndYear" var="err" >
  <spring:bind path="accountBean.${err}" >
  <c:if test="${status.error}">
  <tr>
    <td valign="top"><div class="attention"></div></td>
    <td valign="middle" align="left">${status.errorMessage}</td>
  </tr>
  </c:if>
  </spring:bind>
  </c:forEach>
</table>

${status.errorMessage}