springboot controller templates html
首先声明:
@Controller注解的类必须要在启动类的子集目录下,否则无法扫描
本文要求:
通过controller层跳转页面到html页面(本篇用到thymeleaf模板)
项目结构展示:

第一步:pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
第二步:application.properties(最后两条可加可不加)
server.port=9999
server.servlet.context-path=/
server.tomcat.uri-encoding=UTF-8
spring.thymeleaf.prefix=classpath:/templates/
#spring.thymeleaf.suffix=.html
#spring.thymeleaf.cache=false
第三步:m3.html(随便写写)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
video{
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<h1>helloword</h1>
<video src="videos/working-man.mp4" muted="" autoplay="" loop=""></video>
</body>
</html>
第四步:controller
@Controller
public class HomePage {
//, produces = "application/json;charset=utf-8"
@RequestMapping(value = "/index")
public String index(){
return "m3";
}
}
实现图片:(谷歌地址栏录入:localhost:9999/index)

总结:
花非花,梦非梦,蝶非蝶,雨非雨,让渺远的梵音穿透天空,直到天之外。伸手,握不住岁月的苍凉。
欢迎大佬留言
springboot controller templates html的更多相关文章
- SpringBoot Controller接收参数的几种方式盘点
本文不再更新,可能存在内容过时的情况,实时更新请移步我的新博客:SpringBoot Controller接收参数的几种方式盘点: SpringBoot Controller接收参数的几种常用方式盘点 ...
- SpringBoot Controller找不到视图路径
在启动类加注解@ComponentScan("com.controller")即可,括号里表示Controller所在包名. 参考:https://blog.csdn.net/ji ...
- SpringBoot Controller 中 HttpServletRequest ServletInputStream 读取不到数据该怎么处理
在Springboot程序启动后,会默认添加OrderedCharacterEncodingFilter和HiddenHttpMethodFilter过滤器.在HiddenHttpMethodFilt ...
- springboot使用百度富文本UEditor遇到的问题一览(springboot controller中request.getInputStream无法读取)
先吐槽一下UEditor作为一个前端的js类库,非要把4种后端的代码给出来,而实际生产中用的框架不同,其代码并不具有适应性.(通常类似其它项目仅仅是给出数据交互的规范.格式,后端实现就可以自由定制) ...
- axios 用 params/data 发送参数给 springboot controller,如何才能正确获取
今天有人遇到接口调用不通的情况,粗略看了一下是axios跨域请求引起了.找到问题,处理就简单多了. 但是我看其代码,发现比较有意思 export function agentlist(query) { ...
- SpringBoot Controller 中使用多个@RequestBody的正确姿势
最近遇到Controller中需要多个@RequestBody的情况,但是发现并不支持这种写法, 这样导致 1.单个字符串等包装类型都要写一个对象才可以用@RequestBody接收: 2.多个对象需 ...
- SpringBoot Controller接收参数的几种常用方式
第一类:请求路径参数1.@PathVariable获取路径参数.即url/{id}这种形式. 2.@RequestParam获取查询参数.即url?name=这种形式 例子GET http://loc ...
- SpringBoot Controller接收参数的几种常用方
第一类:请求路径参数 1.@PathVariable 获取路径参数.即url/{id}这种形式. 2.@RequestParam 获取查询参数.即url?name=这种形式 例子 GET http:/ ...
- springboot controller传参,对象映射
Post请求,对象映射时,在参数 加 @RequestBody: 传入对象内字段的json才能映射 {"legendData": [100,90,80,70,60,50,40,30 ...
随机推荐
- D. Feeding Chicken(构造)
题目大意:将k个鸡放到一个n*m的矩阵中,要求每个鸡所占的rice的个数只差最小 题解:构造,设一共有cnt个rice,可以分cnt/k个,即每一只鸡要么占用cnt/k个rice,要么占cnt/k+1 ...
- lua学习之逻辑运算符not,and,or
根据某度查询,lua中的逻辑运算符和其他高级语言大不相同,balabala.我们来看看 广大网友怎么说吧. 版本1: 版本2: 版本3: 揭晓答案: lua中的逻辑与或非与其他语言无差别,都是正常的 ...
- git多人协作操作流程
git协作工作流程 git checkout work 自己工作分支工作 git commit -a -m ''自己工作分支提交 git checkout master 切换到主分支 git pull ...
- python os模块判断文件是否存在
import os os.path.exists(test_file.txt)
- Java IO 流 -- 设计模式:装饰设计模式
在java IO 流中我们经常看到这样的写法: ObjectOutputStream oos = new ObjectOutputStream( new BufferedOutputStream(ne ...
- c++动态数组的使用
在c++中,有的时候会遇到变长的数组(不管是一维的还是二维的),这个时候就需要用到动态数组了,并且要用new和delete两个操作符,这俩操作符一般成对使用. 先说一维的动态数组吧,直接上代码 #in ...
- beego微信网页授权
beego.Get("MP_verify_Rj3QAbcdU0MRsyS.txt", func(context *context.Context) { context.Respon ...
- Inno Setup [Run] Section 双引号嵌套
https://stackoverflow.com/questions/26257808/inno-setup-how-to-run-a-code-procedure-in-run-section-o ...
- 虚拟化KVM之安装(二)
安装KVM虚拟化 1.系统基础环境: [root@linux-node1 ~]# ip addr | grep inet | awk '{ print $2; }' | sed 's/\/.*$//' ...
- asList和ArrayList不得不说的故事
目录 简介 创建ArrayList UnsupportedOperationException asList 转换 总结 asList和ArrayList不得不说的故事 简介 提到集合类,ArrayL ...