MVC Flashcards

1
Q

Layers of Spring MVC

A

-request from web browser
-front controller
-controller
-view template
-back to browser

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

Components of Spring MVC app

A
  • web pages for UI components
  • collection of spring beans
  • spring configuration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Another name for front controller

A

DispatcherServlet

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

Which part of Spring MVC is given to you already complete?

A

the front controller (part of the Spring framework)

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

What does the controller class do?

A

Business logic - handles requests, store/retrieve data, place data in model.

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

What does the model do?

A

contains data, store/retrieve data from backend (DB, web service, etc).

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

What does the view template do?

A

displays data from the page the dev creates.

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

step 1. create controller class process

A

//define class & annotate with @Controller
public class HomeController(){

}

//@Controller inherits from @Component, so it’s a specialized component

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

Step 2. define controller method

A

public class HomeController(){
public String showPage(){

}
}

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

Step 3. add request mapping to controller method

A

public class HomeController(){
@RequestMapping(“/”)
public String showPage(){

}
}

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

Step 4. return view name

A

public class HomeController(){
@RequestMapping(“/”)
public String showPage(){
//view name
return “main-menu”;
}
}

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

Step 5. develop view page

A

<h2>Spring MVC demo home page</h2>

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

Application flow for reading form data

A

request mapping (www.website.com/showForm) -> HelloWorldController (shows JSP form) -> request mapping (www.website.com/processForm) -> HelloWorldController -> display JSP confirmation page

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

What can you put in the spring model?

A

Anything, really. Strings, objects, info from DB, etc. Your view page (JSP) can access data from the model.

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

Reading form data using @RequestParam allows you to _______

A

read form data & automatically bind it to a parameter you’re passing your method

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

What are request mappings & why add them to a controller?

A

All request mappings on methods in the controller are relative paths like in directories. Helps with ambiguity.