Skip to content

Commit 7f68137

Browse files
author
liqiangqiang
committed
Spring Boot WebFlux 整合 Thymeleaf
1 parent 86aedc5 commit 7f68137

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

springboot-webflux-4-thymeleaf/src/main/java/org/spring/springboot/webflux/controller/CityWebFluxController.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ public Mono<Long> deleteCity(@PathVariable("id") Long id) {
4646
return cityHandler.deleteCity(id);
4747
}
4848

49+
@GetMapping("/hello")
50+
public Mono<String> hello(final Model model) {
51+
model.addAttribute("name", "泥瓦匠");
52+
model.addAttribute("city", "浙江温岭");
53+
54+
String path = "hello";
55+
return Mono.create(monoSink -> monoSink.success(path));
56+
}
57+
4958
private static final String CITY_LIST_PATH_NAME = "cityList";
5059

5160
@GetMapping("/page/list")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-CN">
3+
<head>
4+
<meta charset="UTF-8"/>
5+
<title>欢迎页面</title>
6+
</head>
7+
8+
<body>
9+
10+
<h1 >你好,欢迎来自<p th:text="${city}"></p><p th:text="${name}"></p></h1>
11+
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)