Springboot如何访问resource下html静态页面
1. 先把我的项目结构包发出来看
2. 首先写好html页面
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'Hello, ' + ${name} + '!'" />
</body>
</html>
这个html是顺手在spring官网复制的,用的thymeleaf模板先引入,所以需要导入依赖。
3. pom.xml中导入thymeleaf依赖
spring-boot-starter-test还有spring-boot-starter-web是我们创建springboot模板的时候自动加的依赖