第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Spring thymeleaf 不會(huì)遍歷列表

Spring thymeleaf 不會(huì)遍歷列表

互換的青春 2023-06-14 15:40:53
我正在嘗試遍歷 List 并在表格中顯示結(jié)果,但表格仍為空??刂破鰼RequestMapping(value="/home")    public String home(Model model) throws IOException {        List<OrderNotify> notifications = new ArrayList<OrderNotify>();        for (int i = 0; i < 10; i++) {            OrderNotify notification = new OrderNotify("1", "2", "3", "4");            notifications.add(notification);                    }            model.addAttribute("notifications", notifications);            return "home";    }home.jsp - 表格<table id="handle" style=" margin:auto">    <tr>        <th>Bestellnummer</th>        <th>Datum</th>        <th>Status</th>        <th>Handlung erforderlich</th>    </tr>    <tr th:each="notify : ${notifications}">        <td th:text="${notify.orderid}"></td>        <td th:text="${notify.date}"></td>        <td th:text="${notify.status}"></td>        <td th:text="${notify.handle}"> </td>    </tr></table>OrderNotify.javapublic class OrderNotify {    public String orderid;    public String date;    public String status;    public String handle;    public OrderNotify(String orderid, String date, String status, String handle) {        this.orderid = orderid;        this.date = date;        this.status = status;        this.handle = handle;    }    public List<String> getAll(){        return null;    }    public String getOrderid() {        return orderid;    }    public void setOrderid(String orderid) {        this.orderid = orderid;    }    public String getDate() {        return date;    }    public void setDate(String date) {        this.date = date;    }    public String getStatus() {        return status;    }    public void setStatus(String status) {        this.status = status;    }    public String getHandle() {        return handle;    }    public void setHandle(String handle) {        this.handle = handle;    }}
查看完整描述

1 回答

?
躍然一笑

TA貢獻(xiàn)1826條經(jīng)驗(yàn) 獲得超6個(gè)贊

Thymeleaf 和 JSP 是兩種不同的服務(wù)器端渲染模板。沒(méi)有配置你不能同時(shí)使用它們。


根據(jù)您的代碼,您應(yīng)該更新使用 Thymeleaf 的設(shè)置

:將 home.jsp 更改為 home.html

b. 將 home.html 移動(dòng)到路徑:src/main/resources/templates

c。在 application.properties 中配置 Thymeleaf:


? ?# Thymeleaf

? ?spring.thymeleaf.prefix=classpath:/templates/

? ?spring.thymeleaf.suffix=.html

? ?spring.thymeleaf.encoding=UTF-8

? ?spring.thymeleaf.mode=HTML5

? ?spring.thymeleaf.cache=false

d. 在 pom.xml 中配置 Thymeleaf 依賴


<dependency>?

? ? <groupId>org.springframework.boot</groupId>?

? ? <artifactId>spring-boot-starter-thymeleaf</artifactId>

</dependency>

對(duì)于Viewing templates,SpringBoot推薦使用Thymeleaf而不是JSP

在SpringBoot應(yīng)用中同時(shí)使用Thymeleaf和JSP,還需要配置更多。


查看完整回答
反對(duì) 回復(fù) 2023-06-14
  • 1 回答
  • 0 關(guān)注
  • 215 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)