idea创建springboot项目无法访问html文件
如意编程网
收集整理的这篇文章主要介绍了
idea创建springboot项目无法访问html文件
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
首先说明,不需要在此处做任何配置:
1、引入thmeleaf模板引擎
<!-- thmeleaf模板引擎 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2、配置application.properties 如下:
spring.thymeleaf.mode=HTML5
spring.thymeleaf.cache=false
spring.thymeleaf.encoding=utf-8
spring.thymeleaf.prefix=classpath:/templates/views/ #该路径自己指定
spring.thymeleaf.suffix=.html
3、html页面放到resources/templates下(可以自己在下面创建包,但要在prefix中指定,或者在controller中配置)
* idea创建的html页面,<meta>标签不是闭合的,需要添加</meta>,感觉thmeleaf太死板,容错率太低
4、controller中如下:
OK,到这里启动springboot就可以了
总结
以上是如意编程网为你收集整理的idea创建springboot项目无法访问html文件的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: HTML元素 表格
- 下一篇: HTML5常见的取值与单位