java - thymeleaf submit button code -


Can anyone explain how to use the Timileff button to work in the following code? Submit?

  & lt ;! DOCTYPE html & gt; & Lt; Html lang = "en" xmlns: th = "http://www.thymeleaf.org" layout: decorator = "master" & gt; & Lt; Top & gt; & Lt; Title & gt; LoginPage & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H1 & gt; Login page & lt; / H1> & Lt ;! - You place any content in a piece below - will appear on the page - & gt; & Lt; Div class = "container" & gt; & Lt; Div class = "row" & gt; & Lt; Div class = "span8" & gt; & Lt; Pth: if = "$ {loginError}" & gt; Wrong user or password & lt; / P & gt; & Lt; Form th: action = "@ {/ new}" th: object = "$ {messageForm}" method = "post" & gt; & Lt; Label = "user" & gt; Username & lt; / Label & gt; & Lt; Input type = "text" th: field = "* {user}" /> gt; & Lt; Br / & gt; & Lt; Label = "password" & gt; Password & lt; / Label & gt; & Lt; Input type = "password" th: field = "* {password}" /> gt; & Lt; Br / & gt; & Lt; Input type = "submit" value = "login" /> & Lt; / Form & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;    

All of the following can be found in this page.

By the first look, I can say that & lt; Form & gt; The template is provided as a standard form with a

POST call when you submit.

This is not more than plain http / html What is added by the structure that the form field is dynamically bound to an underlying object, which is th: object = "$ {messageForm}" is referred to by attribute.

Each field is calculated by calling a method on th: field = "* {password}" syntax with messageForm object .

Finally, the post call is created, the URL created by evaluating th: action = "@ {/ new}" attribute, possibly relative to the current page.


We make an example to clarify. Suppose we have

  • one object messageForm type MessageForm
  • user Type string
  • password type string
  • providing the template URL "Http://my.app.com/login"

    with a web page, what you get from submitting a button is that The message format will have its properties in the user and password Set the values ​​that are kept in the respective fields of that form, and call a "http://my.app.com/new" page from the form, or similarly, Message Form to check the credentials for the login operation from the object ...


    If you do not already, then I strongly advise you to read Before the thymeleaf website.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -