SpringMVC - JSP迭代问题
我尝试将以下类用作命令对象
public class Member {
private String datePeriod;
private String status;
private ArrayList <Project> projectList;
}
在 JSP 上,我希望表单预填充预先存在的值。
<c:forEach items="${member.projectList}" var="project">
<tr>
<td><form:input path="**<var???>**" value="${project.projectEntry.projectDesc}" /></td>
</tr>
</c:forEach>
我的路径错误导致 jsp 中出现错误。有谁知道每次迭代的正确语法?谢谢。
I have the following class that I am attempting to use as a command object
public class Member {
private String datePeriod;
private String status;
private ArrayList <Project> projectList;
}
On the JSP, I would like the form to prefill with a pre-existing values.
<c:forEach items="${member.projectList}" var="project">
<tr>
<td><form:input path="**<var???>**" value="${project.projectEntry.projectDesc}" /></td>
</tr>
</c:forEach>
I am making an error with path which is causing an error in jsp. Does anyone know the proper syntax with regards to each iteration? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的 Spring MVC 有点生疏,但如果我没记错的话,路径最终会被翻译为 HTML 中的输入名称属性。因此,您可以在其中放置任何标签值,这应该可以工作。
这应该翻译为:
您想从支持 bean 中查找名称吗?如果是这样,您应该能够执行如下操作。在不知道你的数据结构的情况下,我假设它是状态。
有关表单标记的更多信息 此处。
My Spring MVC is bit rusty but if I remember correctly, path gets translated as the input name property in HTML eventually. So you can put any Label value in there and that should work.
<form:input path="ProjectDescription" value="${project.projectEntry.projectDesc}" type="text" />
This should get translated to:
<input name="ProjectDescription" type="text" value="<whatever_you_have_in_backing_bean>"/>
Do you want to look up name from a backing bean instead? If so you should be able to do something like below. Without knowing your data structure I am assuming it to be status.
<form:input path="member.status" value="${project.projectEntry.projectDesc}" type="text" />
More on the form tag here.