thymeleaf登录失败提示

<div id="darkbannerwrap">
    <span style="color: green; font-size: 16px; 
          font-family: 楷体" 
          th:text="${msg}"        
          th:if="${not #strings.isEmpty(msg)}">
    </span>
</div>

//thymeleaf转换日期格式
<td th:text="${#dates.format(user.getBirthday(),'yyyy-MM-dd HH:mm:ss')}"></td>

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,这是一个较为简单的问题。你可以按照以下步骤实现: 1. 创建教师表 首先,我们需要创建一个教师表,用于存储教师的信息,包括账号和密码等信息。可以通过MySQL等数据库来创建该表,例如: ``` CREATE TABLE teacher ( id INT NOT NULL AUTO_INCREMENT, username VARCHAR(50) NOT NULL, password VARCHAR(50) NOT NULL, PRIMARY KEY (id) ); ``` 2. 配置Spring Security 在Spring Boot中,我们可以使用Spring Security来实现登录功能。在配置Spring Security时,我们需要指定登录页面、登录成功后的跳转页面、用户名和密码的字段名等信息。可以在application.properties或application.yml中添加如下配置: ``` # 配置登录页面和登录成功后的跳转页面 spring.security.login-page=/login spring.security.default-target-url=/student/list # 配置用户名和密码的字段名 spring.security.user.name=username spring.security.user.password=password # 配置教师账号密码 spring.security.user.password=teacher:123456 ``` 3. 创建登录页面 在templates目录下创建login.html文件,该文件用于显示登录页面。可以使用Bootstrap等前端框架来美化页面,例如: ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>登录页面</title> <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css"> </head> <body> <div class="container"> <form method="post" action="/login"> <div class="form-group"> <label for="username">账号:</label> <input type="text" class="form-control" id="username" name="username"> </div> <div class="form-group"> <label for="password">密码:</label> <input type="password" class="form-control" id="password" name="password"> </div> <button type="submit" class="btn btn-primary">登录</button> </form> </div> </body> </html> ``` 4. 创建学生列表页面 在templates目录下创建student-list.html文件,该文件用于显示学生列表页面。可以使用Thymeleaf等模板引擎来动态渲染页面,例如: ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>学生列表页面</title> <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css"> </head> <body> <div class="container"> <h1>学生列表</h1> <table class="table"> <thead> <tr> <th>学号</th> <th>姓名</th> <th>班级</th> </tr> </thead> <tbody> <!-- 使用Thymeleaf动态渲染表格数据 --> <tr th:each="student : ${students}"> <td th:text="${student.id}"></td> <td th:text="${student.name}"></td> <td th:text="${student.className}"></td> </tr> </tbody> </table> </div> </body> </html> ``` 5. 创建Controller 在Controller中添加@RequestMapping注解,用于处理登录请求和显示学生列表页面请求。例如: ``` @Controller public class LoginController { @Autowired private TeacherRepository teacherRepository; @Autowired private StudentRepository studentRepository; @RequestMapping(value = "/login", method = RequestMethod.GET) public String login() { return "login"; } @RequestMapping(value = "/student/list", method = RequestMethod.GET) public String studentList(Model model) { List<Student> students = studentRepository.findAll(); model.addAttribute("students", students); return "student-list"; } } ``` 6. 运行应用程序 最后,运行应用程序并访问http://localhost:8080/login,就可以看到登录页面了。输入正确的账号和密码,就可以跳转到学生列表页面了。如果账号或密码不正确,会提示错误信息。 以上是一个简单的实现教师登录并显示学生列表页面的过程,具体实现可能还需要根据实际情况进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值