springboot访问html文件
来源:互联网 发布:java用sleep内存泄露 编辑:程序博客网 时间:2024/06/07 12:51
在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包,不然找不到
阅读全文
0 0
- springboot访问html文件
- 通过SpringBoot访问HTML页面
- Springboot下swagger-ui.html访问不到
- springboot-静态文件 js,css,html等
- Springboot搭建web项目访问自定义位置的html页面
- 【系统学习SpringBoot】初见Thymeleaf之SpringBoot访问项目中的 jsp/html
- 访问资源中的html文件
- HTML 访问本地 Markdown 文件
- SpringMVC下访问Html文件
- IIS能访问html文件,但aspx文件访问不了
- 访问HTML文件与访问php文件的区别
- apache 指定访问index.html文件
- 解决springMVC不能访问.html文件
- springboot-aop访问拦截
- SpringBoot的数据访问
- SpringBoot-访问MySQL数据库
- springboot访问jsp页面
- springboot 跨域访问
- 登录注册常用JQuery逻辑
- 数据导出到excel中,出现表情包,自身数据能导出,后续数据导致空白丢失,表情过滤。
- UML_使用Astah对C++代码反向建模(a.k.a cpp代码映射为类图的教程)
- 配置mysql 主从同步(mysql版本5.7.18
- Android 实现启动页面冷启动
- springboot访问html文件
- Visual Studio Code创建C#项目
- 图像bayer格式介绍以及bayer插值原理CFA
- 教你开发jQuery插件
- bcache ssd hdd
- SpringAOP的几种配置
- cloudera Manager 配置报警邮箱
- 程序中打印的
- phantomjs 简介