如何在Thymeleaf页面中显示ArrayList对象

时间:2017-08-02 09:54:28

标签: java arrays arraylist thymeleaf

我尝试在Thmeleaf页面中显示Public Shared Sub Log(ex As Exception) Try Dim oBestand As New System.IO.StreamWriter(My.Computer.FileSystem.SpecialDirectories.Desktop & "\ErrorLog.txt", True) If Not IsNothing(oBestand) Then oBestand.WriteLine("") oBestand.WriteLine(My.Computer.Clock.LocalTime.ToString) oBestand.WriteLine(ex.Message) oBestand.WriteLine(ex.StackTrace) oBestand.WriteLine("_________________________________________") oBestand.Close() End If Catch exc As Exception End Try End Sub 对象,但我得到了值Arraylist
我可以在控制台上的控制器中显示arraylist。我在功能中传递arraylist的方式是否正确。

在控制器中

null

html page

@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";
}

1 个答案:

答案 0 :(得分:0)

我通过在模型

中添加arraylist解决了这个问题
model.addAttribute("rowTypes2", rowTypes2);