0
ThraleafページにArraylistオブジェクトを表示しようとしましたが、値がnullになっています。 arraylistをコンソールのコントローラに表示できます。それは私が機能のarraylistを渡す方法が正しいです。コントローラでThymeleafページに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>
をArrayListのを追加することで問題を解決しました。コードは他の方法でも本当に奇妙に見えますが、チュートリアル/ドキュメントでもう少し時間を過ごすことをお勧めします。 – Kayaman
ArrayListを 'Search'メソッドと同じようにモデルに追加します。 –
'model.addAttribute(" rowType "、new RowType());'私はこの行を疑っています。 – soorapadman