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/,就可以了