ben*_*_14 1 spring-mvc thymeleaf
我是 Thymeleaf 的新手。刚刚读过它,现在,我尝试在前端使用 Thymeleaf 显示一些文本,在后端从 Spring MVC 获取值。
文件 successPwd.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta charset="UTF-8"/>
<title>Password Change</title>
</head>
<body>
<h2>Password Changed</h2>
Your password has been changed. Your account information is below.
Username: [[${account.username}]] <br/>
First Name: [[${account.firstName}]] <br/>
Last Name: [[${account.surname}]] <br/>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
文件 PasswordResetController.java
@RequestMapping(value= "/user/new_password", method = RequestMethod.POST)
public String saveNewPassword(@RequestParam(value="new_password",required=false) String password, @RequestParam(value="hash") String hash, Model model)
{
//some codes to check hash
AccountInfo account = accountInfoService.getAccount(hash);
model.addAttribute("account", account);
return "/successPwd";
}
Run Code Online (Sandbox Code Playgroud)
我得到的是这样的:
Password Changed
Your password has been changed. Your account information is below.
Username: [[${account.username}]]
First Name: [[${account.firstName}]]
Last Name: [[${account.surname}]]
Run Code Online (Sandbox Code Playgroud)
Thymeleaf 没有转换为正确的值,很可能我在这里错过了一些非常非常基本的东西。
| 归档时间: |
|
| 查看次数: |
9912 次 |
| 最近记录: |