两种情况:

1、如果使用了 thymeleaf 模板引擎,html文件可以放在 template文件夹中,如果不是一定不要放进去,否则找不到,因为html是静态页面,所以放在把此类文件放在了static文件夹下。

15、springboot访问html文件

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

在resources\templates\hello.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<title>Hello World!</title>
</head>
<body>
<h1 th:inline="text">Hello.v.2</h1>
<p th:text="${hello}"></p>
</body>
</html>

在Controller中加入

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

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

会跳转到页面

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

2、如果没有使用任何模板引擎,则html文件要放在static文件夹中,因为属于静态文件。

最新文章

  1. QT 网络编程
  2. C语言回滚(二)--循环打印
  3. 听说你会打地鼠(动态规划dp)
  4. Android 中如何使用动画
  5. 贪心-hdu-1789-Doing Homework again
  6. 在IIS上Office Word下载失败,检索 COM 类工厂中 CLSID 为000209FF的组件失败,80070005 拒绝访问。
  7. [转]整理jquery开发技巧
  8. 如何查询oracle中的关键字
  9. Myeclipse详细使用教程
  10. C/C++知识点清单02-上
  11. BZOJ 1593: [Usaco2008 Feb]Hotel 旅馆 [线段树]
  12. Django学习笔记(5)——cookie和session
  13. input的type类型
  14. jmeter IP欺骗功能
  15. 4.Python爬虫入门四之Urllib库的高级用法
  16. C# MemoryStream BinaryReader
  17. 进程ID[PID(Process ID)]与端口号[(Port ID)]的联系
  18. MVC多语言设置 实战简洁版
  19. 象“[]”、“.”、“-&gt;”这类操作符前后不加空格
  20. jmeter 之 BeanShell PostProcessor跨线程全局变量使用

热门文章

  1. java用String类的toUpperCase()和toLowerCase()方法转字符串的大小写
  2. django http404 详解
  3. memcached(一):linux下memcached安装以及启动
  4. [LintCode] Subarray Sum &amp; Subarray Sum II
  5. EditText: EditText自动获取焦点并弹出键盘&amp;EditText不自动获取焦点并且不会弹出键盘
  6. Virtual Memory$$memory-mapped-files
  7. django rest_framework入门五-认证和权限
  8. Android 开发添加控件事件的三种方式
  9. Python通过ssh连接服务器并执行命令
  10. python-minidom模块【解析xml】