Meaning MVC mode, SSM frame, three-tier architecture, Java developers a common package name

What is the MVC model?

M model model - programming proper function, data management and database design.

V view view layer - interface design interface design.

C controller control - the controller is responsible for forwarding the request to process the request.

What is SSM framework?

SSM is Spring + Spring MVC + Mybatis abbreviation of the mainstream of enterprise-class Java EE framework.

Which, Spring is a lightweight Inversion of Control (IOC) and aspect-oriented (AOP) of the container frame, you can help us create the object.

Spring MVC control development, allowing developers a simple specification.

MyBatis persistence framework is a Java-based, encapsulates CRUD operations.

 

Spring

See this, many people will say to you what Inversion of Control (IoC), dependency injection (DI), AOP, what matters ...... for the novice, what are these ghosts do?

Inversion of Control

I do not write definitions say about your computer. It has a usb port on your computer, it has hdmi port. What are the keyboard with the computer, it does not depend on the computer itself, but what is plugged into the usb keyboard was? This can understand it. You see what control computer input devices not controlled by the computer, but what you insert the keyboard to control. This control is not yet on the counter?

Dependency Injection

It is the inversion of control. Computer input devices rely on it to be inserted is what the keyboard. Insert mechanical keyboard, mechanical keyboard input device that is inserted into the numeric keypad to enter numbers only. From this matter, it is inserted keyboard: simply from the perspective of the computer, dependency injection, what input device is a keyboard is dependent injection; from the keyboard is a control point of view inversion, insertion of the keyboard to control what the computer input device.

Why use dependency injection? The purpose is that you can be flexible with. If the keyboard on your computer is welded on the computer keyboard is broken, your computer can scrap it. You certainly do not want that.

Java development, we need to create a large number of objects, some important objects indeed affect the whole body, such objects we can to help us to create Spring, we only need to provide the configuration file, the configuration file can be xml, also It can be java itself. Spring is like a factory, we can make products according to the drawings.

AOP

What is the cut? You may think: a company has multiple sales, need help to get the daily administrative order stationery, tickets, office, hotel on a business trip or something, we need to get financial reimbursement, what matters right collection and payment, to help shipping warehouse What. Not every sales went to recruit several administrative, financial and warehouse what it, as long as the sales department to do business on the line, what things stationery order to pay a special department of running on the line.

In Spring AOP, these public affairs, that is, in this example ah administrative, financial, ah, ah warehouse, as one section, let your development time, focus on core business.

Affairs

Said an example: For example, I Alipay transferred to you 100 dollars, 100 normal operation should be missing from my account, you are more than 100. If for various reasons, my little 100, the system problem. No transaction words, your account will not be more than 100, and my account number 100 less. This is a problem. There is a transaction if: You want me little more than 100 100 were successful, or to not succeed, so the money will not less. The handwriting of a transaction or a little difficulty, Spring's transaction (spring-tx) can help us easily.

Spring MVC

This, then, you must first understand what MVC is?

C - Controller: controller. Accepting user requests, call the Model treatment, and then select the appropriate View to the customer.

M - Model: Model. Business process model, accepted Controller disposal, handling business, process the data.

V - View: view. Returns the result to the client to see. Note that clients may not be the person may be a browser, perhaps APP.

So surely you do not understand, for example: you go to a restaurant for dinner, sit down, the waiter sister came to take your order. You made a point of kung pao chicken, I took your sister carte menu are Houchu. Master Houchu open food storage cabinets, find chicken, open stove, put oil, stir-fried meal, transfer to a plate. The young girl put that plate back to your table. Of course, if you feel handsome young girl, maybe even sneak a chicken for you; if you happen to be the year of the young girl broke up with ex-boyfriend, maybe the young girl would Spit inside.

Here, you are the customer, you order is a request (Request), the young girl is Controller, is Houchu Model, sister and finally to the plate and which is the content of View, sister to give you the dish is a response (Respond). Controller processing customer requests, feedback to the Model. Model processing, and returns data (Gongbaojiding) to the Controller (sister). The young girl can give you direct, you can add chicken or give to you after spat. In the end, you got a eat (View).

Spring MVC MVC is a framework, and Spring inherently integrated.

MyBatis

And a framework to help you deal with the database. Help you translate database tables into classes, field translated into class fields, records translated into objects. (Of course, these are all on your own definitions.)

Consequences of doing so is that you can write java the same operation as the database. What open JDBC, prevent sql injection, do not consider, MyBatis seal the deal.

Spring, by simply setting can be integrated MyBatis framework, so there will be argument SSM framework.

 

If we SSM framework + some additional functions as a desktop computer, plug the keyboard, mouse, monitor, USB, audio ...... then Spring Framework on the host computer seems to be the host, Spring MVC similar to the display (Web interaction is very beautiful , right), MyBatis like a hard drive (removable hard disk, USB), other features such as frame Shiro security framework is like a fingerprint registrar. These things are not all plug on the host?

 

Three-tier architecture

Architect three means: the view layer view, service layer service, persistence layer Dao, their function is:

1.view layer: codes for receiving a user request, such as how to distribute the request;

2.service layer: the business logic of the system is mainly written in here, such as the library system will have a library of business;

3.Dao layer: Direct operation code database, the reason Dao sub-layer, mostly likely the same sql statement may be used in more places, change when change can be understood as only one can be.

To reduce the coupling, where the use of abstract-oriented programming, that is, the upper layer calls to the lower layer, be done directly through the interface, the lower the provider of the true service the upper layer, the interface implementation class underlying implementation, the implementation class can be replaced , which achieved a decoupling between the layers.

The difference between MVC and three-tier architecture

MVC architecture inside the Controller and View layers are combined together is the three-tier architecture View layer, and the MVC Model layer contains the three-tier Service layer and the layer Dao.

Common package name meaning Java development

Java:

  bean entity class, the corresponding table in the database, construction methods, properties, getters the setter, toString ()
  DAO persistence layer database CRUD
  service business layer
  controller layer jump control where

resources:

  mapper dao implementation class
  applicationContext.xml Spring configuration files
  db.properties database connection information
  log4j.properties log configuration file
  springmvc.xml configuration springmvc

webapp:

  jsp page and other
  Web-INF
  the web.xml to load filter interceptor

 

 

 

 

Guess you like

Origin www.cnblogs.com/SallyShan/p/12667057.html