MVC Flashcards
1
Q
- What is MVC Pattern?
A
- It is not specific for java but for all languages . To design patterns
Model- Responsible for Storing and retrieving data (OS)
View- User Interaction (monitor), Responsible for rendering of model UI.
Controller - Responsible for responding for user input (eg.remote)
This is for loosely coupled
Desktop is loosely coupled
Laptop is tight coupled
By controller we are telling ->model to do this -> model will give view to View
2
Q
1.What Controller will do ?
2.Spring Mvc Architect?
A
- Controller will handle all the servlet request, but it wont do directly, it will give to Front Controller which is (Dispatcher Servlet)
- Client send the request -> We have Front controller that is Dispatcher Servlet -> Here we will be having @handler mapping where it will tell the request type to the “Controller”-> in controller there will be many servlets , then it will send to ->Model Service ( model will fetch the data from DB, SQL, then it will return to the model , Note: model will not give the thing how its getting it will in a view , here model view will discuss in which view we need to give them ( View Resolver will do that which is in Spring boot) Model will discus whether need to give in Jsp or thyme leaf or html or Json or any other format we need to give.
3
Q
- where html files and Jsp files will be there in Springboot?
2.What @Controller will do ?
3.What is @Request Mapping? - What is @Response body?
- What we need to give in While we want to return jsp?
A
- Usually inside Src-.main->
- For Request handling
- If we give controller , how i will know this method should be called., so for that we need to use . @requestmapping(“index). html page name pass here .
4.The @ResponseBody annotation is used to bind the return value of a controller method directly to the response body, bypassing the default view resolution process. I - We need to give return(“index.jsp”); so it will work.
and we need to add jasper dependency.