0

我正在使用一个 Spring Tag 表单元素,其中有 3 个参数。

<sf:form class="form-horizontal" method="post" name="doCheck" id="checkForm" action="${url}" htmlEscape="true">
<div class="col-sm-12">
                        <label>Email : <span class="redStar">*</span></label>
                        <input type="email" name="email" class="form-control user inputIconPos" id="inputEmail3" 
                            placeholder="Email Address"/>
                    </div>
                </div>
//2 more fields
</sf:form>

我正在使用 Spring MVC 版本4.1.7和 HDIV 版本2.1.11。记录的错误是

21:08:40.386 [http-bio-8100-exec-4] INFO  org.hdiv.logs.Logger - INVALID_PARAMETER_NAME;/check_submit.html;email;null;;0:0:0:0:0:0:0:1;0:0:0:0:0:0:0:1;anonymous;
21:08:40.386 [http-bio-8100-exec-4] DEBUG o.hdiv.filter.ValidatorHelperRequest - Validation Error Detected: Parameter [email] does not exist in the state for action [/check_submit.html]

HDIV 配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:hdiv="http://www.hdiv.org/schema/hdiv"
xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.hdiv.org/schema/hdiv http://www.hdiv.org/schema/hdiv/hdiv.xsd">
<hdiv:config excludedExtensions="css,png,gif,jpg,jpeg,bmp,ico,js"  strategy="cipher" randomName="true" errorPage="/error.html" reuseExistingPageInAjaxRequest="true">
    <hdiv:sessionExpired loginPage="/login.html" homePage="/home.html"/>
    <hdiv:startPages>/adminlogin.html,/home.html</hdiv:startPages>
</hdiv:config>
<hdiv:validation id="safeText">
    <hdiv:acceptedPattern><![CDATA[^[a-zA-Z0-9@.\-_]*$]]>  </hdiv:acceptedPattern>
</hdiv:validation>
<hdiv:editableValidations registerDefaults="true">
    <hdiv:validationRule url=".*" enableDefaults="true">safeText</hdiv:validationRule>
</hdiv:editableValidations>
</beans>

我不想从验证中排除这些参数。我想知道如何配置 HDIV 以使这些参数得到验证并且不被跳过。提前谢谢了!

4

2 回答 2

1

您必须使用 Spring 表单标签来创建表单字段:

<form:input path="email" type="email" ... />

戈宗

于 2015-08-31T07:23:17.723 回答
0

您需要在 hdiv 配置中添加以下配置以跳过参数验证 -

<hdiv:paramsWithoutValidation>
      <hdiv:mapping url=".*" parameters="email"/>
</hdiv:paramsWithoutValidation>

如果您想在此特定页面上提供此信息,url您可以提供。"/check_submit.html"

于 2018-11-02T10:45:45.377 回答