如何在 spring mvc 表单中将列表显示为表格
public class Parent {
private Integer Id;
private String name;
private String age;
private List<Childrens> childrens;
// getters and setters
}
我的 JSP 类:
<spring:bind path="parent.*">
<c:if test="${not empty status.errorMessages}">
<div class="error">
<c:forEach var="error" items="${status.errorMessages}">
<img src="<c:url value="/images/iconWarning.gif"/>"
alt="<fmt:message key="icon.warning"/>" class="icon" />
<c:out value="${error}" escapeXml="false" />
<br />
</c:forEach>
</div>
</c:if>
<form:form commandName="parent" method="post"
action="parent .html" onsubmit="return onFormSubmit(this)"
id="parentForm">
<appfuse:label styleClass="desc" key="name" />
<form:errors path="name" cssClass="fieldError" />
<form:input path="name" id="name" cssClass="text medium"
readonly="true" cssErrorClass="text medium error" />
<appfuse:label styleClass="desc" key="age" />
<form:errors path="age" cssClass="fieldError" />
<form:input path="age" id="cage" cssClass="text medium"
readonly="true" cssErrorClass="text medium error" />
我想将 Children
列表显示为表格。我该怎么做呢?表单页面内的列表。
public class Parent {
private Integer Id;
private String name;
private String age;
private List<Childrens> childrens;
// getters and setters
}
My JSP classs:
<spring:bind path="parent.*">
<c:if test="${not empty status.errorMessages}">
<div class="error">
<c:forEach var="error" items="${status.errorMessages}">
<img src="<c:url value="/images/iconWarning.gif"/>"
alt="<fmt:message key="icon.warning"/>" class="icon" />
<c:out value="${error}" escapeXml="false" />
<br />
</c:forEach>
</div>
</c:if>
<form:form commandName="parent" method="post"
action="parent .html" onsubmit="return onFormSubmit(this)"
id="parentForm">
<appfuse:label styleClass="desc" key="name" />
<form:errors path="name" cssClass="fieldError" />
<form:input path="name" id="name" cssClass="text medium"
readonly="true" cssErrorClass="text medium error" />
<appfuse:label styleClass="desc" key="age" />
<form:errors path="age" cssClass="fieldError" />
<form:input path="age" id="cage" cssClass="text medium"
readonly="true" cssErrorClass="text medium error" />
I want show list of Children
s as a table. How can I do it? A list inside form page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许你最好的选择是使用内置的 jstl 标签库(你已经有了)来声明 bean 并获取子项列表并使用“forEach”迭代它们。
据我所知,使用 spring 表单标签并不会阻止您执行此操作。
Probably your best bet is to use the built-in jstl tag lib (which you already) to declare the bean and get the list of children and iterate over them with "forEach".
Using spring form tag doesn't prevent you from doing this as far as I know.