SpringBoot的templates

templates

使用这个包下的文件 需要导入jar 包 并且在页面接收templates包下文件的数据需要添加约束

jar包

 		<dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-thymeleafartifactId>
        dependency>

页面依赖

<html lang="en"  xmlns:th="http://www.thymeleaf.org">

templates的简单语法


<div th:text="${msg}">div>

<div> [[ ${msg} ]]div>


<div th:utext="${msg2}">div>

<div th:each="user :  ${msglist} " th:text="${user}">div>

<div th:each="user :  ${msglist} ">[[ ${user} ]]div>

简单的增删改查


<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
head>
<body>
    <table>

        <thead>
            <tr>
                <td>idtd>
                <td>账号td>
                <td>密码td>
        thead>
			
        <tr th:each="user,index:${list}">
            <td th:text="${index.index}">td>
            <td th:text="${user.getId()}">td>
            <td th:text="${user.getName()}">td>
            <td th:text="${user.getPassword()}">td>
            <td><a th:href="@{'/login/remove/'+${user.getId()}}">删除a>td>
        tr>
    table>

    <hr/>
    <hr/>
    <hr/>
    <h1>添加用户h1>
    <form th:action="@{/login/add}" method="post">
        id:<input type="text" name="id" />
        用户名:<input type="text" name="name" />
        密码:<input type="text" name="password" />
        <input type="submit" value="提交" />
    form>

    <hr/>
    <hr/>
    <hr/>
    <h1>修改用户h1>
    				
    <form th:action="@{/login/updata}" method="post">
        id:<input type="text" name="id" />
        用户名:<input type="text" name="name" />
        密码:<input type="text" name="password" />
        <input type="submit" value="提交" />
    form>

body>
html>

你可能感兴趣的:(JAVA,java,spring,boot)