【发布时间】:2016-04-07 15:04:38
【问题描述】:
创建规则列表的Java类
public class CompArray {
public ArrayList<Rules> a1= new ArrayList<Rules>();
public CompArray (){
Rules rul = new Rules();
rul.setruleId("1001");
rul.setruleName("khagfkj");
rul.setParameter("lsrkjglkrs");
rul.setValue("lskdjfk");
a1.add(rul);
}
public ArrayList<Rules> getRules(){
return a1;
}
规则列表控制器
@RequestMapping(value = "/demo", method = RequestMethod.GET)
public String listRules1(ModelMap model) {
CompArray obj1 = new CompArray();
model.addAttribute("listRule1", obj1.a1);
return "hello";
}
我想将动态值放在列中的html表
<c:if test="${not empty listRule1}">
<table border ="2">
<tr>
<th align="center"><b>Rule ID</b></th>
<th align="center"><b> Rule Name </b></th>
<th align="center"><b>Rule Type </b></th>
<th align="center"><b>Rule Validity </b></th>
<th align="center"><b>Parameter </b></th>
<th align="center"><b>Value</b></th>
</tr>
<c:forEach items="${listRule1}" var="obj1">
<tr>
<td>${obj1.id}</td>
<td>${obj1.details}</td>
<td>${obj1.parameter}</td>
<td>${obj1.value}</td>
</tr>
</c:forEach>
</table></c:if>
如何将动态值放在特定列中? 请有人帮我做这件事。我尝试了很多解决方案,但无法解决这个问题。
【问题讨论】:
-
No of th 应该等于 td 的数量。第一个 th 对应于第一个 td 等等。如果您能告诉我们您得到了什么,我们或许可以提供帮助。
-
@sashwat,当我调用 servlate 时,值以连续的方式出现在列中,我的意思是 Rule_Id 和 Rule_Name 放置在 excat
中,但参数和值放置在 Rule_Type & Rule_Validity,我想把它放在 Parameter & Value 列中 再添加两个 td,如下所示。${obj1.id} ${obj1.details} ${obj1.parameter} ${obj1.value} @sashwat,这样我会得到值,但我怎么能把它放在一个精确的列中。先生,请告诉我一些细节“动态价值”是什么意思?如果您只想刷新 tds 的值,请使用 ajax。