在Thymeleaf中执行Java方法
可以在${....}中对后端传入的对象直接使用属于它的方法即可。
使用map的size()方法: @GetMapping("/en") public String en(ModelMap map) { HashMap<String, Integer> hashMap = new HashMap<>(); hashMap.put("aa", 2); hashMap.put("a", 1); hashMap.put("aaa", 3); hashMap.put("aaaa", 4); map.addAttribute("words",hashMap); ...
<th th:text="|单词(${words.size()})|"></th>

浙公网安备 33010602011771号