MVC design Pattern
Model View Controller
Model: Represents business data and business logic < databases and pojo>
View: The interface that the user sees and interacts with
Controller: Accept user input and invoke model and view to complete user's needs
< accepts the request and decides which model component is called to process the request, and then decides which view to call to display the data returned by the model processing >
MVC Case < No business layer and transactional operations >
Technical JSP, Servlet used
Database using MySQL
Connecting the database using the C3PO database connection pool
The JDBC tool uses Dbutils
Prompt action on the page using JQuery
Technical difficulties:
How multiple requests use a servlet
Fuzzy query
Verify that the user name exists in the case of creation or modification and give a hint
function of view-->jsp
1) Rendering data
2) Accept the user's input
3) write the JS code to give the corresponding hints
The function of controller-->servlet
1) Get request information: GET request parameters
2) Verify the validity of the request parameters: validation failed, need to return to page, and give the prompt information
3) package The request parameters as a JavaBean
4) Call the DAO method to get the returned result
5) Put the returned results in the request
6) Response page: Forward, redirect
function of Model-->dao
1) Get Data connection database
2) Perform CRUD operations
3) return results
MySQL Database
< Jsp-->servlet-->dao-->mysql
-->dao-->servlet-->jsp >
Attention:
1) cannot be accessed across tiers!
2) can only be dependent on the upper and lower, but not from the bottom up dependent < as the servlet relies on the DAO in the Dao,servlet interface, but DAO can not have the interface of the servlet, this is a mess >
Development sequence: Database----------and JSP, servlet
MVC design Pattern