当前位置:网站首页>MVC three-tier architecture

MVC three-tier architecture

2022-06-23 05:08:00 Don't want to be a programmer

When MVC:Model View Controller

Servlet and JSP Can write Java Code ; Easy to maintain and use in the future ;

  • Servlet Focus on processing requests , And control view jump
  • JSP Focus on displaying data
Controller– controller View View layer Model
ServletJSPJavaBean
Receive user requests Show the data model pojo、entity
Leave it to the business layer to do Provide user operation
View jump

 Insert picture description here
User direct access control layer , The control layer can directly operate the database

servlet--CRUD--> database 
 disadvantages : The program is very bloated , Not conducive to maintenance  servlet In the code of : Processing requests 、 Respond to 、 View jump 、 Handle JDBC、 Processing logic code 

 framework : Nothing can't be solved by adding a layer 

 Insert picture description here
Model

  • Business processing : Business logic (Service)
  • Data persistence layer :CRUD(Dao)

View

  • Display data
  • Provide links to initiate Servlet request (a, form, img…)

Controller(Servlet)

  • Receive requests from users :(req: Request parameters 、Session Information )
  • Give it to the business layer to process the corresponding code
  • Control the jump of the view
 Sign in --- Receive login requests from users ---> Handle user requests ( Get user login parameters ,username,password)---> Leave it to the business layer to handle the login business ( sentence 
 Whether the user name and password are correct : Business )--->Dao The layer queries whether the user name and password are correct --> database 
原网站

版权声明
本文为[Don't want to be a programmer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230136591778.html