SPRING BOOT WEB MVC
MVC is a design pattern used to implement Web Application.
M=Model(Data/Entity Classes)
V=View(UI/HTML)
C=Controller(Request processing code)
*)Controller supports HTTP Protocol(Request/Response)
1)Project/Application->Modules
2)Gmail App->Idex,User Register/Login etc.
3)BusTicket->User,Search,BookTicket etc.
1Module=1Controller
Ex:-UserController
HandlerMapping
==============
Key(Path+Http Method) Value(Controller)
-------------------- -------------------
/emp/show(GET) EmployeeController(show data())
/std/save(POST) StudentController(save data())
Execution Flow
==============
#1 Browser makes request to server in 3 different ways.
a) Enter URL in addressbar[GET](http://facebook.com)
b) Click Hyper links[GET](<a> tags)(logout,Inbox etc)
c) HTML form submit[POST](Register,login).
#2 Request is sent to server.
HTTP request contains 2 parts.
Head+Body
#3 Spring Framework(Web MVC) has provided one pre-defined servlet names as:
Dispatcher Servlet(c)
This the only Entry and Exit point.i.e. It will read request and finally it gives response back.
#4 Front Controller gives Path and method details to HandlerMapping.
#5 Front Controller(FC) back controller and method details.
#6 Front Controller will call method by reading object from container like:
Ex:-empController.showData()
1 request=1 time method is called
#7 Controller(is a class) contains request processing code(inside methods)
these are executed by FC.
->Browser is sending login data,validate it.
->Browser is asking for logout.
->Browser is asking to post one comment[save data in db and reflect back to UI]
Controller also provides data(if requireed/i.e option)
NOTE:-
-----
Controller must returns ViewName
->Model stores data in key(String)=Val(Object)Format
Model
======
Key value
---- -------
UserName Shailja
Logintime 12:40 16/2/2021 IST 4:00
#10 FC reads ViewName and takes help of ViewResolver(class)that provides
prefix (location od UI pages)and Suffix(extension)
Prefix=/webpages/myviews/
Suffix=.html
ViewPage= Prefix + ViewName + Suffix
#12 FC finally gets ViewPage details and calls/execute UI page.
#13 UI reads data from Model memory and replaces all expression with actual data.
#14 Final UI(View) is given back to FC.
#15 FC send data as Response back to browser.
#16 Browser will display UI page.