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