1. What is framework? A framework is a collection of classes and interfaces that coordinate the implementation of a program. With a framework, we can focus on the development of business logic without worrying about its technical implementation and some ancillary business logic. To put it bluntly, a framework is a package of programmer friendly classes that makes the development of a project easier and easier to maintain. The framework’s ontology is actually a collection of JAR packages and configuration files. 2. Why use frameworks? The advantages of the framework are as follows: (1) focus on the business logic design of the system; (2) The program is easier to expand and maintain, and the stability is stronger; (3) Deal with many details of the system, such as security issues.
(3) Add framework configuration files (e.g. Struts-config.xml) to specify how the framework handles various behaviors (e.g., when a request is received, (4) Write business logic (inheritance, implementation of the framework of the class, interface) to complete specific processing operations.
1. What is MVC? MVC is a programming architecture that enforces the separation of input, processing, and output from an application. An application using MVC is divided into three core components: the model, the view, and the controller. They each handle their own tasks. M: Model, business logic. V: View, user interface. C: Controller, which coordinates the business logic (M) and user interface (V).
2. For example
The most typical MVC is JSP + Servlet + Javabean pattern:
M: Receive instructions from controller (C), complete business logic, perform database operations, and then transfer data to [controller (C) or view (V)]
V: Get the data from [controller (C) or model (M)] and render the results to the user interface.
C: Intercepts the user request, invokes business logic (M) to complete the operation (and then passes the data to the user interface (V))
3. Mainstream MVC architecture: SSH and SSM (1)SSH: Struts2 is the controller (C), Spring manages the components of each layer, and Hibernate is responsible for the persistence layer. (2)SSM: SpringMVC is the controller (C), Spring manages the components of each layer, and MyBatis is responsible for the persistence layer. (3) Common: ①Spring dependency injection DI to manage the components of each layer. ② Use section-oriented programming AOP to manage transactions, logs, permissions, etc. (4) Differences: ①Struts2 and SpringMVC controllers (C) different interaction mechanisms for controlling views and models, ②Struts2 is Action class level, SpringMVC is method level, which is easier to implement RESTful style. (5)SSM differs from SSH mainly in MVC implementation and ORM persistence (Hiibernate and Mybatis). SSM is more and more lightweight configuration, annotation development to the extreme, and ORM implementation is more flexible, SQL optimization is easier; SSH, on the other hand, pays more attention to configuration development. Hiibernate is more object-oriented in the complete encapsulation of JDBC and more automatic in the maintenance of data adding, deleting, changing, and checking. However, IT is weak in SQL optimization and has a higher threshold for entry.
1.Spirng Spring provides a consistent approach to managing business objects and encourages the injection of good habits for programming interfaces rather than classes. Spring’s architecture is based on an Inversion of Control container that uses JavaBean properties. However, this is only one part of the complete picture: Spring is unique in using the IoC container as a complete solution for building a complete focus on all architectural layers. Spring provides a unique data access abstraction, including a simple and efficient JDBC framework that greatly improves efficiency and reduces possible errors. Spring’s data access architecture also integrates Hibernate and other O/R mapping solutions. Spring also provides a unique transaction management abstraction that provides a consistent programming model across various underlying transaction management technologies, such as JTA or JDBC transactions. Spring provides an AOP framework written in the standard Java language that gives POJOs declarative transaction management and other enterprise transactions — if you need them — and the ability to implement your own Aspects. The framework is powerful enough to allow applications to dispense with the complexities of EJBs while enjoying the key services associated with traditional EJBs. Spring also provides a powerful and flexible MVC Web framework that can be integrated with the IoC container.
2.Struts2
Hibernate is an open source object-relational mapping framework, which has carried out a very lightweight object encapsulation of JDBC, so that Java programmers can use object programming thinking to manipulate the database as they wish. Hibernate can be applied in any use of JDBC occasions, both in Java client application, can also be used in Servlet/JSP Web applications, the most revolutionary significance is that Hibernate can be applied in EJB J2EE architecture to replace CMP, complete the task of data persistence.
4.SpringMVC
5.Mybatis
If you need more Java learning materials can be private xiaobian “learning” to obtain oh ~