mirror of
https://gitee.com/coder-xiaomo/java-note
synced 2025-01-25 18:50:26 +08:00
8
This commit is contained in:
parent
104b5faaf4
commit
b4ca336f6f
@ -4682,7 +4682,7 @@ src/main/webapp/WEB-INF/web.xml
|
||||
|
||||
|
||||
|
||||
##### 使用
|
||||
##### Thymeleaf的使用
|
||||
|
||||
###### 启动
|
||||
|
||||
@ -4707,7 +4707,7 @@ src/main/webapp/WEB-INF/templates/login.html
|
||||
|
||||
|
||||
|
||||
##### 运用
|
||||
###### 运用
|
||||
|
||||
src/main/webapp/WEB-INF/templates/login.html
|
||||
|
||||
@ -4757,8 +4757,32 @@ src/main/webapp/WEB-INF/templates/success.html
|
||||
|
||||
|
||||
|
||||
##### 语法
|
||||
|
||||
> Thymeleaf的主要作用是把model中的数据渲染到HTML中,因此语法主要是如何解析model中的数据
|
||||
|
||||
###### 变量(基本类型:String、int、...)
|
||||
|
||||
控制器代码
|
||||
|
||||
src/main/java/org/example/web/UserController.java
|
||||
|
||||
```java
|
||||
@RequestMapping("/add")
|
||||
public String addUser(Book book, Model model) {
|
||||
// 把书籍名称存储起来
|
||||
model.addAttribute("name",book.getBookName());
|
||||
return "success";
|
||||
}
|
||||
```
|
||||
|
||||
页面获取
|
||||
|
||||
通过 `tx:next=${控制器传递过来的参数}` 显示文本内容
|
||||
|
||||
```html
|
||||
<span th:text="${name}">空</span>
|
||||
```
|
||||
|
||||
|
||||
## 提升
|
||||
|
Loading…
x
Reference in New Issue
Block a user