Spring Tag表格中出现HDIV INVALID_PARAMETER_NAME错误

时间:2015-08-30 14:15:55

标签: spring-mvc spring-security hdiv

我使用的是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,以便验证这些参数,而不是跳过这些参数。 非常感谢提前!

2 个答案:

答案 0 :(得分:1)

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

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

Gotzon

答案 1 :(得分:0)

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

a

如果要在此特定页面上输入,请在<hdiv:paramsWithoutValidation> <hdiv:mapping url=".*" parameters="email"/> </hdiv:paramsWithoutValidation> 中输入url

相关问题