一、thymeleaf的使用
1.1、导入pom
<!--thymeleaf-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
1.2、前端页面
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1 th:text="${msg}">哈哈</h1>
<h2>
<a href="www.qq.com" th:href="${link}">百度一下</a></br>
<a href="www.qq.com" th:href="@{/link}">百度一下</a></br>
</h2>
</body>
</html>
@Controller
public class ViewController {
@GetMapping("/testSuccess")
public String testSuccess(Model model){
model.addAttribute("msg","老莫,吃鱼了");
model.addAttribute("link","http://www.baidu.com");
return "success1";
}
}