Spring boot thymeleaf 報錯:HTTP Status 500 – Internal Server Error

Spring boot thymeleaf 報錯:HTTP Status 500 – Internal Server Error

pom.xml已經引入

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

application.yml的配置:

spring:
  application:
    name: test-thymelead
  thymeleaf:
    cache: false
    prefix: classpath:/templates
    suffix: .html
    mode: HTML
    encoding: UTF-8
    servlet:
        content-type: text/html

控制器:

@Controller
@RequestMapping("/test")
public class TestController {
    @RequestMapping("/greet")
    public String greetUser() {
        return "login";
    }
}

資源頁面

然後啓動報錯:HTTP Status 500 – Internal Server Error

原來是配置中的

prefix: classpath:/templates後面漏了一個“/”,加上上去爲prefix: classpath:/templates/,就可以了
發佈了133 篇原創文章 · 獲贊 45 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章