【发布时间】:2016-04-06 20:43:49
【问题描述】:
我有一个从列表中检索的数据,我想将它们准确地放置在我该如何做到这一点,请给出一个有用的建议。
创建列表的java类
import java.util.ArrayList;
import com.demo.Rules;
public class CompArray {
public ArrayList<Rules> a1= new ArrayList<Rules>();
public CompArray (){
Rules rul = new Rules();
rul.setId("1001");
rul.setDetails("khagfkj");
rul.setParameter("lsrkjglkrs");
rul.setValue("lskdjfk");
a1.add(rul);
}
公共 ArrayList getRules(){
返回a1;
}
}
控制器
@RequestMapping(value = "/compplan", method = RequestMethod.GET)
public String listRules1(ModelMap model) {
CompArray obj1 = new CompArray();
model.addAttribute("listRule1", obj1);
return "hello";
}
HTML
<c:if test="${!empty listRule1}">
<table border ="2">
<tr>
<th align="center"><b>ID</b></th>
<th align="center"><b>Details </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>
我正在这样做,但它没有在表格中显示值,请帮助我。
提前致谢
【问题讨论】: