微服务 教程
1085个小节阅读:196.7k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
xxxxxxxxxx
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
spring-boot很多配置都有默认配置,比如默认页面映射路径为
xxxxxxxxxx
classpath:/templates/*.html
同样静态文件路径为
xxxxxxxxxx
classpath:/static/
在application.properties(或者application.yml)中可以配置thymeleaf模板解析器属性.就像使用springMVC的JSP解析器配置一样
xxxxxxxxxx
#thymeleaf start
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
#开发时关闭缓存,不然没法看到实时页面
spring.thymeleaf.cache=false
#thymeleaf end
xxxxxxxxxx
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<link rel="shortcut icon" href="../resources/favicon.ico"
th:href="@{/static/favicon.ico}"/>
<head>
<meta charset="UTF-8">
<title>首页</title>
</head>
<body>
<a href="/addUser">添加用户</a> <a
href="/user/getUser">查询用户</a>
</body>
</html>
xxxxxxxxxx
@Controller
public class PageController {
/**
* 完成页面跳转
*/
@GetMapping("/{page}")
public String showPage(@PathVariable String page){
return page;
}
}