Thymeleaf Error resolving template [index],template might not exist or might not be accessible
生活随笔
收集整理的這篇文章主要介紹了
Thymeleaf Error resolving template [index],template might not exist or might not be accessible
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
文章目錄
- 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=.html2. 視圖層
做路徑跳轉
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)建頁面
根據(jù)業(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的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 企业微信_新建自建H5小程序应用及主页与
- 下一篇: kibana-7.15.2 一分钟下载、