通过SpringBoot访问HTML页面
来源:互联网 发布:c语言判断数字函数 编辑:程序博客网 时间:2024/05/22 01:57
本文章内容主要讲下怎么通过SpringBoot进入HTML页面
1、首先在pom.xml添加对HTML的相关依赖
/** * pom.xml文件 */<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency></dependencies><build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins></build>**
2、在application.yml文件添加SpringBoot相关配置
spring: thymeleaf: prefix: classpath:/templates/
3、创建HTML文件
/** * 路径:resources/templates */<!DOCTYPE html><html lang="en" xmlns:th="http://www.w3.org/1999/xhtml"><head> <meta charset="UTF-8"/> <title>第一个HTML页面</title></head><body><h1>Hello Spring Boot!!!</h1><p th:text="${hello}"></p></body></html>
4、在Controller里面写跳转HTML页面方法
@Controller //注意这里必须为Controllerpublic class HelloController { /** * 本地访问内容地址 :http://localhost:8080/lmycc/hello * @param map * @return */ @RequestMapping("/hello") public String helloHtml(HashMap<String, Object> map) { map.put("hello", "欢迎进入HTML页面"); return "/index"; }}
5、访问页面
好了,这样就可以通过SpringBoot正常访问HTML页面了,快去试试吧!
源码下载地址:http://download.csdn.net/download/sinat_33889619/10038775
阅读全文
0 0
- 通过SpringBoot访问HTML页面
- 通过.html访问jsp页面
- Springboot搭建web项目访问自定义位置的html页面
- springboot访问html文件
- springboot访问jsp页面
- springboot访问jsp页面
- 关于springboot访问页面
- android webView中的html页面通过javascript访问java代码
- springboot--页面访问拦截器
- springboot配置跳转html页面
- 通过cookie访问页面
- Springboot下swagger-ui.html访问不到
- SpringBoot项目如何访问jsp页面
- SpringBoot项目如何访问jsp页面
- SpringBoot访问JSP页面的完整代码
- 通过代理服务器 访问 Internet页面。
- springmvc通过URL页面访问
- mvc4 访问静态html页面
- Golang 在 Mac、Linux、Windows 下如何交叉编译
- IntelliJ IDEA 创建web项目1(4)
- MVC request生命周期
- SQL注入工具sqlmap使用手记
- Docker基础命令
- 通过SpringBoot访问HTML页面
- python中子类调用父类的初始化方法
- Ubuntu定时任务——crontab
- Handler改变ImageView
- 第八周项目二
- C++面试常见题目问与答(汇总一)
- 微信测试号开发之二 封装消息实体类
- eclipse经常卡在某validating进程上?
- 访问者模式(行为模式)