Ch11: Thymeleaf Views Flashcards
Define template
Provides general structure for a web page. Editing a template modifies all pages using the template.
A template represents a ____ in MVC
view
What information does the following line in a thymeleaf template provide?
xmlns provides the syntax to IDE that will be used by the template
In a method that sends data to a template:
A ___ parameter is an object that stores the variable names and values passed into a template
model
Ex: public String methodName(Model model) {}
In a method that sends data to a template:
____ statements add data to the model object
addAttribute
Ex: model.addAttribute(“variableName”, variableValue);
In a method that sends data to a template:
___ contains the path and file name for the desired template
return string
Ex: dogs.html in animals subfolder = “animals/dogs”
Thymeleaf commands appear as ____ in standard HTML tags
attributes
The data available to a template includes variables and values stored in the ____ objects, and are accessible with by syntax ____.
model, ${variableName}
Describe the use of default text in a template
Help visualize planned layout for the webpage while under development. It improves readability, and indicates what data will appear in each section
What is th used for in the following statement:
prefix indicates beginning of a thymeleaf command
What does the following code achieve in thymeleaf?
th:each = “variableName : ${collectionName}”
Iterates through a collection. Repeats tag that contains th:each statement
${ } This syntax indicates what?
Data provided by controller/model object that is referenced by the template.
th:block is a Thymeleaf _____ which allows application of a Thymeleaf attribute to a block of code
element
Does th:block get rendered in the view?
No
List some benefits of using th:block
- helps clarify HTML code by placing related Thymeleaf attributes into separate tags
- can group together tags you want to be displayed in a given order (ex. heading/paragraph pair)
- can set up nested loops