首页 > 编程语言 > 详细

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

时间:2020-04-06 21:55:20      阅读:961      评论:0      收藏:0      [点我收藏+]

 

首先说明,不需要在此处做任何配置:

技术分享图片

 

 

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文件

原文:https://www.cnblogs.com/lychee-wang/p/12644073.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!