springboot访问html文件


1  在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

2 在resources\templates\hello.html

3 在Controller中加入

@RequestMapping("/hello")
    public String helloHtml(HashMap map){
        map.put("hello","HelloWord"); return"/hello"; 
}
 

启动,然后输入localhost:8080/hello

会跳转到页面

注意:必须加入thymeleaf包,不然找不到