SPRING MVC Flashcards

1
Q

What are three things that an MVC controller uses and how is it annotated?

A

Model, View and a @Controlller

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How are methods written in the @Controller?

Annotation, returns etc.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Model and what does the it do?

A

The communication vessel between the Controller and the View

Holds data that can be displayed in the View

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Where does the model get its data?

A

In the Controller Method-body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a View?

A

Template for the web page that is returned to the client (web browser)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does a View “do”?

A

Gets access to the Model to be able to display data from the Model in the
generated web page

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you display data from the model?

public String test (Model model)
model.addAttribute(“name”, value);
return “names”;

A

•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>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly