zoukankan      html  css  js  c++  java
  • thymeleaf的基本用法

    添加thymelleaf依赖

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

    1.例如登录验证 ,前端代码例子

    <!DOCTYPE html>
    <html xmlns:th="http://www.thymeleaf.org" >

    <head>
    <!-- 页面meta -->
    <meta charset="utf-8">

    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="/css/theme-chalk.css">
    <link rel="stylesheet" href="/css/login_style.css">
    </head>


    <form class="loginForm clear" th:action="@{/loginverify}" method="post">
    <div class="loginMain">
    <div class="loginlogo"></div>
    <p style="color:red" th:text="${message}" th:if="${not #strings.isEmpty(message)}"></p>
    <div class="loginCon">
    <span class="el-form-item">

    <span class="userIcon"></span>
    <span class="el-input">
    <input class="el-input__inner" name="username" required="" autofocus="" placeholder="账号"/>
    </span>
    </span>


    2.后端代码建议使用modelandview
    public ModelAndView postViewLogin(ModelAndView mv, HttpServletRequest request, HttpSession session) throws NoSuchAlgorithmException {
    String username = request.getParameter("username")
    User user = userDao.findAllByUsername(username);
    if(user==null){
    mv.addObject("message","用户名或密码错误");
    mv.setViewName("login");
    return mv;

    }
    }

  • 相关阅读:
    软件测试(来自于网络)
    selenium常用命令
    新员工入门
    常用测试点
    测试leader职责
    软件测试 —— 用例设计4(读书分享)
    Tomcat 基础二
    Github Pull Request的提出与采纳
    Unix套接字接口
    健壮的I/O(RIO)
  • 原文地址:https://www.cnblogs.com/liushuaibiao/p/13163726.html
Copyright © 2011-2022 走看看