java - thymeleaf 提交按钮代码

标签 java maven thymeleaf

谁能解释一下 thymeleaf 的提交按钮在以下代码中是如何工作的?

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

  layout:decorator="master">
<head>
    <title>LoginPage</title>
</head>

<body>
 <h1>Login Page</h1>
<!-- Any content you put in the div fragment below will appear on the page-->
<div class="container">
<div class="row">
    <div class="span8">

    <P th:if="${loginError}" >Wrong User or Password</P>

        <form th:action="@{/new}" th:Object="${messageForm}"        
                    method="post">
        <label for ="User">User Name</label>
        <input type="text" th:field="*{user}"/><br/>
        <label for ="password">Password</label>
        <input type="password"  th:field="*{password}"/><br/>
        <input type="submit" value="Login" />
        </form>

        </div>
</div>
</div>
 </body>
 </html>

最佳答案

<form>模板被渲染为带有 POST 的标准表单。您提交时调用的电话。
该框架添加的内容是,表单字段动态绑定(bind)到底层对象,由 th:Object="${messageForm}" 引用。属性。

每个字段都是通过调用 messageForm 上的方法来计算的带有 th:field="*{password}" 的对象语法。

最后,POST调用通过评估 th:action="@{/new}" 创建的 URL属性,可能相对于当前页面。

关于java - thymeleaf 提交按钮代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15539287/

相关文章:

java - 如何获取 ConcurrentHashMap 的最新 View ?

javascript - Map<String, String> 未映射

spring - 2.1.4 中没有 org.springframework.ws.transport.http.HttpsUrlConnectionMessageSender

javascript - 如何将动态表中的数据存储到数据库中

java - Thymeleaf 依赖导致 Spring 工具套件中出现 "Error: Could not find or load main class"

java - 在android中显示电子邮件(JavaMail Message)的最佳方式

java - 从java中的文本文件中读取字符串和整数

javax.mail 的 Maven 依赖项

java - 使用 Felix & Maven 创建一个完整的 OSGi 应用程序

spring - Thymeleaf:消息作为另一个消息的参数