Hello I have a simple web page where I have a button and a text near to button. I need to change text when button clicked and get the new text from code.
This is con
Change
?????
To
${stream}
OR
How it is working?
You can access variables value by ${key}.
Example
model.addAttribute("key", value);
Get value by ${key}
in HTML
In Thymeleaf, these model attributes (or context variables in Thymeleaf jargon) can be accessed with the following syntax:
${attributeName}
, where attributeName in our case isstream
. This is a Spring EL expression. In short, Spring EL (Spring Expression Language) is a language that supports querying and manipulating an object graph at runtime.
UPDATE
The th:field attribute can be used on input, select, or, textarea.
Replace ?????
with
OR
`
OR
Also try [[${stream}]] /> Thymeleaf Document Thymeleaf Document Inputs UPDATE 2 Get value from Thymeleaf to Spring Boot Note: use "th:field" for Entity/Model
;
@GetMapping("/send")
public String send(@RequestParam(name="doc", required = false) String doc) {
//change required = false as per requirement
System.out.println("Doc: "+doc);
return "textarea-input";
}