JavaBean and MVC

Original link: http://www.cnblogs.com/lhy_2011/p/4046390.html

JavaBean

JavaBean is a follow specific wording of java classes. Follow several rules
1.java classes must have a no argument constructor.
2. The property must be privatized.
3. The privatization of property must be exposed to other programs (getter, setter) type of approach by the public

<jsp: bean id = "beanName " class = "package.clss" scope = "page | request | session | application"> </ jsp: bean> is returned if there is no presence creates a new
<JSP: setProperty>
< jsp: getProperty>


<jsp: bean>
body
</ JSP: bean>
body inside content can only be <jsp: bean> tag creates javaBean when execution


jsp development modes:
Mode 1:
the JSP the JavaBean + Mode
This mode is suitable to develop less complex business logic of the web application.
In this mode. JavaBean used to encapsulate business data, jsp responsible for handling user requests a page and reality

Mode two:
the Servlet + + the JavaBean the JSP mode
This mode is suitable to develop complex applications deweb, in this mode, the servlet responsible for handling user requests.
jsp responsible for real data, javabean responsible for encapsulating data, Servlet + JSP + Javabean mode.
A clear hierarchy between the various program modules, web developers recommend the use of this model.

MVC principles of three-tier architecture

First, we divided the web server

Client, Servlet, Service layer, dao layer, db database
WEB layer (Service Interface) layer service (DAO Interface) data access layer
1. Servlet requesting client to
2.Servlet request is received -> servlet component to call servicce processing requests
3.service component processes the request, when data is needed, call the dao layer to get data
4.dao layer receives a request, through JDBC to the database to find data.
The database returns data to the dao layer,
6.dao layer receives data returned by the database, by a good package JavaBean data.
7.dao layer encapsulated data back to the Service layer
8.Service layer to get data, process the data. The processed data to reseal JavaBean.
9.service assembly is finished, the encapsulated JavaBean returned to the Servlet
10.Servlet not suitable for output, the data is forwarded to get jsp.
11.jsp out javaBean data pages filled with good.
12.jsp sends the page to the client.

Reproduced in: https: //www.cnblogs.com/lhy_2011/p/4046390.html

Guess you like

Origin blog.csdn.net/weixin_30685047/article/details/94795656