一、首先在pom.xml添加对HTML的相关依赖java
/**
* pom.xml文件
*/
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>**
二、在application.yml文件添加SpringBoot相关配置web
spring:
spring
thymeleaf: prefix: classpath:/templates/
注意:application.yml 若是是空文件,则默认视图文件存放在templates文件下,资源文件存放在static目录下,因为SpringBoot对jsp支持不太友好,通常使用自带的标签实现数据的赋值

在Controller里面写跳转HTML页面方法ruby
@Controller //注意这里必须为Controller public class HelloController { /** * 本地访问内容地址 :http://localhost:8080/lmycc/hello * @param map 传递参数 * @return */ @RequestMapping("/hello") public String helloHtml(HashMap<String, Object> map) { map.put("hello", "欢迎进入HTML页面"); return "/index"; } }