0
在Java/springboot的代码:打印键/从散列映射thymeleaf值/数组列表
@RequestMapping(value = "results")
public String results(
Model model,
@RequestParam String searchType,
@RequestParam String searchTerm) {
model.addAttribute("columns", ListController.columnChoices);
ArrayList<HashMap<String, String>> jobsbyval = JobData
.findforValue(searchTerm);
model.addAttribute("items", jobsbyval);
return "search";
}
在HTML/thymeleaf的代码:
<div>
<table>
<tbody>
<tr th:each="item : ${items}">
<!--each loop begins -->
<td th:text="${item}"></td> //item.value or item.key dont work!!
</tr>
<!--loop ends -->
</tbody>
</table>
</div>
下面是HTML输出中。
{header 1=something, header 2=Analyst, category 3=somename, location=somewhere, skill=Stats}
将所需的HTML输出(键/值),以表格形式将是:
header 1 something
header 2 Analyst
category somename
location somewhere
skill Stats
非常感谢您编辑代码并输出整齐。我在编辑器中尝试过无数次,但没有成功。再次感谢你!! – aguy01