首页 > 编程语言 > 详细

springboot访问html文件

时间:2018-04-20 15:14:07      阅读:267      评论:0      收藏:0      [点我收藏+]

1  在pom.xml加入


<parent>

   <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version>

</parent>

<dependencies>

   <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>

        <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot</artifactId> <version>1.2.0</version>

       </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency>

       <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency>

       <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>

</dependencies>

2 在resources\templates\hello.html

3 在Controller中加入

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

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

会跳转到页面

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

springboot访问html文件

原文:https://www.cnblogs.com/mytdbky/p/8890865.html

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