使用HTML+thymeleaf写一个登录页面
时间: 2024-01-12 07:02:37 浏览: 17
以下是一个使用 HTML 和 Thymeleaf 模板引擎编写的登录页面示例:
```html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Login</title>
</head>
<body>
<h1>Login</h1>
<form th:action="@{/login}" method="post">
<p>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
</p>
<p>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</p>
<p>
<input type="submit" value="Login">
</p>
</form>
</body>
</html>
```
在这个示例中,我们使用 Thymeleaf 的表达式语言来动态生成 HTML 标签的属性值。例如,`th:action="@{/login}"` 属性会动态生成表单的 `action` 属性值为 `/login`。这个示例中的表单使用 `POST` 方法提交,提交的字段包括 `username` 和 `password`。