码迷,mamicode.com
首页 > 编程语言 > 详细

springboot访问html文件

时间:2018-04-20 16:17:31      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:nbsp   source   frame   public   跳转   java   connect   mybatis   找不到   

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文件

标签:nbsp   source   frame   public   跳转   java   connect   mybatis   找不到   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!