0

我的 JSP 中有以下代码:

<form:form id="detailsForm" modelAttribute="project" method="post" action="${contextPath}/project/create">

<form:input type="hidden" path="id" value="${project.id}"/>

<form:input type="text" class="form-control" path="name" value="${fn:escapeXml(project.name)}"/><br/>

<form:input type="text" class="form-control" path="location" value="${fn:escapeXml(project.location)}"/><br/>

<form:input type="text" class="form-control" path="notes" value="${fn:escapeXml(project.notes)}"/><br/>

<button class="btn btn-default btn-flat btn-sm">Update</button>

</form:form>

这似乎不起作用。如果我单击该Update按钮,控制台将记录一个错误INVALID_CONFIDENTIAL_VALUE

但是,一个也有 POST 方法但没有任何参数的表单似乎可以工作:

<form:form action="${contextPath}/project/delete/${project.id}" method="post">

	<button class="btn btn-default btn-flat btn-sm">Delete This Project</button>

</form:form>

我的表格可能有什么问题?

我有以下 HDIV 配置:

<beans:bean id="hdivEditableValidator" class="org.hdiv.web.validator.EditableParameterValidator"/>
<mvc:annotation-driven validator="hdivEditableValidator"/>

<!-- Accepted pattern within the application for all editable parameters (generated from textbox and textarea) -->
<hdiv:validation id="safeText">
	<hdiv:acceptedPattern><![CDATA[^[a-zA-Z0-9@.\-_]*$]]></hdiv:acceptedPattern>
</hdiv:validation>

<hdiv:editableValidations>
	<hdiv:validationRule url=".*" enableDefaults="false">safeText</hdiv:validationRule>
</hdiv:editableValidations>

<hdiv:config
		debugMode="true"
		errorPage="/fix"
		excludedExtensions="css,png,gif,jpeg,jpg,js,woff,woff2,map"
		randomName="true"
		strategy="cipher">
		<hdiv:sessionExpired loginPage="/auth/login" homePage="/"/>

		<hdiv:startPages>/</hdiv:startPages>
		<hdiv:startPages method="get">/auth/denied,/fix,/,/auth/login,/auth/logout,/dashboard/,/image/display/project/profile/,/pmsys/image/display/staff/profile/</hdiv:startPages>
		<hdiv:startPages method="post">/j_spring_security_check</hdiv:startPages>
	</hdiv:config>

4

1 回答 1

0

我通过在表单中​​指定一个 commandName 解决了我的问题

<form:form id="detailsForm"
                  											commandName="project"
                  											method="post"

将隐藏输入转换为:

<form:hidden path="id"/>

于 2015-04-15T07:29:14.403 回答