简体   繁体   English

在Struts 1.2中验证后保留表单值

[英]Keep form values after validation in struts 1.2

Hi i am building a webapp with struts 1.2 嗨,我正在使用Struts 1.2构建Web应用程序

I am building an "edit" form, so i have my input tags being pre populated from a bean: 我正在构建“编辑”表单,因此我的输入标签是从Bean中预先填充的:

form.jsp form.jsp

<html:text property="population"
value="${city.population}"/>

Later on, i use struts validation 稍后,我使用struts验证

The problem is, i have 10 form elements, if one of them fails by the validation rules, the action gets back to the form and populates de elements with the bean data and not with the resently changed data of the user. 问题是,我有10个表单元素,如果其中之一未通过验证规则,操作将返回表单并使用bean数据而不是用户最近更改的数据填充de元素。

I wan 我要

The problem is due to the value attribute you have there. 问题是由于您在那里拥有value属性。 The property attribute should be enough to show the correct value in the input. property属性应足以在输入中显示正确的值。 Having value there will always cause the value of ${city.population} to be displayed. 在该处有value将始终导致显示${city.population}的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM