欢迎访问 如意编程网!

如意编程网

当前位置: 首页 > 前端技术 > HTML >内容正文

HTML

idea创建springboot项目无法访问html文件

发布时间:2022/11/16 HTML 32 老码农
如意编程网 收集整理的这篇文章主要介绍了 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中如下:

idea创建springboot项目无法访问html文件

 

 OK,到这里启动springboot就可以了

总结

以上是如意编程网为你收集整理的idea创建springboot项目无法访问html文件的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得如意编程网网站内容还不错,欢迎将如意编程网推荐给好友。