我尝试Arraylist
在 Thmeleaf 页面中显示对象,但我得到null
了值。
我可以在控制台上的控制器中显示数组列表。我在函数中传递 arraylist 的方式是否正确。
在控制器中
@RequestMapping("/searchSummon")
public String Search(Model model) {
model.addAttribute("summonsDetailType", new SummonsDetailType());
model.addAttribute("rowType", new RowType());
return "searchSummon";
}
@RequestMapping(value = "/searchProcess", method = RequestMethod.POST)
public String searchProcess(SummonsDetailType summonsDetailType, RowType rowType) {
ArrayList<RowType> rowTypes2 = new ArrayList<RowType>();
SummonsDetailType summonsDetailType2 = pdxiRes.getRequest().getSummonsDetail();
for (RowType rowType3 : summonsDetailType2.getRow()) {
rowTypes2.add(rowType3);
}
System.out.println(rowTypes2.get(0).getDistrictCode());
return "/searchResult";
}
html页面
<tr th:each="rowType : ${rowType}">
<td th:text="'NRIC NO: ' + ${rowType.DistrictCode}"></td>
</tr>
我通过在模型中添加数组列表解决了这个问题
model.addAttribute("rowTypes2", rowTypes2);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句