springboot controller templates html

首先声明:html

  @Controller注解的类必需要在启动类的子集目录下,不然没法扫描spring

 

本文要求:json

  经过controller层跳转页面到html页面(本篇用到thymeleaf模板)tomcat

 

项目结构展现:app

 

 

 

第一步:pom.xmlide

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

第二步:application.properties(最后两条可加可不加)spring-boot

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(随便写写)oop

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

第四步:controllerspa

@Controller
public class HomePage {
//, produces = "application/json;charset=utf-8"
@RequestMapping(value = "/index")
public String index(){
return "m3";
}
}

实现图片:(谷歌地址栏录入:localhost:9999/indexserver

 

 

 

 

总结:

花非花,梦非梦,蝶非蝶,雨非雨,让渺远的梵音穿透天空,直到天以外。伸手,握不住岁月的苍凉。

 

欢迎大佬留言

相关文章
相关标签/搜索