SPRING MVC Flashcards
What are three things that an MVC controller uses and how is it annotated?
Model, View and a @Controlller
How are methods written in the @Controller?
Annotation, returns etc.
Methods are mapped to Http-requests eg. @GetMapping(“/”)
And always selects a view by returning the name of the view.
eg. return “book”;
Could also possibly build a model with data passed on to the View
What is a Model and what does the it do?
The communication vessel between the Controller and the View
Holds data that can be displayed in the View
Where does the model get its data?
In the Controller Method-body
What is a View?
Template for the web page that is returned to the client (web browser)
What does a View “do”?
Gets access to the Model to be able to display data from the Model in the
generated web page
How do you display data from the model?
public String test (Model model)
model.addAttribute(“name”, value);
return “names”;
•Display data from the Model:
<h1></h1>
•Repetitive statement (iterate over a list):
<li>
•Conditional statement (will only display the tag if condition is true):
<h1></h1></li>