[警告] 我是 JSP/Struts/JSTL 新手。这可能是一个新手问题:)
我有一个包含集合的表单:
public class ServiceForm extends AbstractForm
{
private List<SrvDO> allSrv = new ArrayList<SrvDO> ();
}
我可以使用 JSP 在表单中正确查看对象数据。页面正确显示5个输入框,其中包含数据库中的数据:
<c:forEach items="${serviceForm.allSrv}" var="srv">
<html:text name="srv" property="nbDays"/>
</c:forEach>
<html:submit/>
但是当我按下提交按钮时,表单不包含“nbDays”的更新数据。我仍然看到与更新前显示的数据相同的数据。我缺少什么对 struts 说:对于每个 srv,更新“nbDays”数据?
最佳答案
在 the spring forum 上找到答案:
Your form:input tag doesn't and shouldn't know anything about the fact that it is used inside another tag. That is why you need to include the index.
所以解决办法是:
<html:text property="allSrv[${srvSta.index}].nbDays"/>
关于java - JSP - 保存集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/542110/