日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Thymeleaf Error resolving template [index],template might not exist or might not be accessible

發(fā)布時間:2024/9/27 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Thymeleaf Error resolving template [index],template might not exist or might not be accessible 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


文章目錄

            • 1. 導入依賴
            • 2. 配置
            • 2. 視圖層
            • 3. 創(chuàng)建頁面
            • 4. 檢查target
            • 5. 表達式

使用Thymeleaf 一共5步,檢查一下看看是否符合規(guī)范

1. 導入依賴
<!--模板引擎--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>
2. 配置

application.properties

# thymeleaf相關配置 spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix=.html
2. 視圖層

做路徑跳轉

package com.imooc.dianping.controller.admin;import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView;@Controller @RequestMapping("/admin/admin") public class AdminController {@GetMapping("/index")public ModelAndView index() {ModelAndView modelAndView = new ModelAndView("/admin/admin/index");return modelAndView;} }
3. 創(chuàng)建頁面

默認:在templates目錄下面創(chuàng)建頁面
根據業(yè)務需求,在templates創(chuàng)建子包路徑,和視圖層相對應

4. 檢查target

檢查文件是否編譯

5. 表達式
<p th:text="${name}"></p>

總結

以上是生活随笔為你收集整理的Thymeleaf Error resolving template [index],template might not exist or might not be accessible的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。