本篇教程介绍了HTML+CSS入门 SpringBoot无法显示html文件如何解决,希望阅读本篇文章以后大家有所收获,帮助大家HTML+CSS入门。
<
两种情况:
1、如果使用了 thymeleaf 模板引擎,html文件可以放在 template文件夹中,如果不是一定不要放进去,否则找不到,因为html是静态页面,所以放在把此类文件放在了static文件夹下。
在pom.xml加入
org.springframework.boot
spring-boot-starter-parent
1.5.2.RELEASE
org.springframework.boot
spring-boot-starter-web
org.mybatis.spring.boot
mybatis-spring-boot
1.2.0
mysql
mysql-connector-java
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-starter-thymeleaf
在resources\templates\hello.html
html>
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
Hello World!Hello.v.2
在Controller中加入
@RequestMapping("/hello")
public String helloHtml(HashMap map){
map.put("hello","hello");
return"/hello";
}
启动,然后输入localhost:8080/hello
会跳转到页面
注意:必须加入thymeleaf包,不然找不到
2、如果没有使用任何模板引擎,则html文件要放在static文件夹中,因为属于静态文件。
本文由职坐标整理发布,欢迎关注职坐标WEB前端HTML/CSS频道,获取更多HTML/CSS知识!