spring:
1) Open source framework
2) IOC (control reversal), write the creation and dependencies of the class in the configuration file, inject the configuration file, realize the loosening coupling
3) AOP will be extracted by security, transaction is equal to the relatively independent functional function of the program logic, and uses Spring configuration files to insert these functions, realize aspect programming
What is the difference between Struts and Spring?
Structs: Like WW2, etc., it is a typical MVC structural framework). Structs focuses on the performance layer. It itself has the role of a controller, that is, Controller, which can separate the expression layer from the business layer. Spring: To put it bluntly, it is a hodgepodge, which provides the current integration of various popular frameworks. The classic is integrated with hibernate. In addition, such as Mail, Axis ... all kinds of. In addition, it is more classic the function of IOC and AOP. In addition, it also provides Spring MVC, which is based on WebFlow. Spring is a combination of a series of web framework technology, which is characterized by lightweight, non -invasive, decoupled design, etc. Generally, the most used is its IOC/di, that is, the reversing control/dependency injection, such as using XML to declare bean and inject it when running.
Since I don't know very well, I don't understand well.
Simply put, the three mainstream open source, the industry's de facto standard framework of Struts Spring Hibernate!
When there was no Struts in the early days, we passed the data in front and back to the front and back, and all of which were used in the use of the scope object (Page, Request, Session, Application), including a large amount of GetParameter and getttribute, as well as data type conversion. I wasted a lot of time. And there are many development of MVC, which has increased the difficulty of later maintenance and the difficulty of secondary development.
In this case, Struts came into being. He provided three major components for us to use it. The front and back database passed the use of ActionForm to pass it, which was directly packaged into objects. Easy to operate. Moreover, as a typical implementation of MVC, the separation of views and control layers has clearer code and more convenient maintenance.
When doing JDBC operations in the early days, I believe everyone has this experience. I write the database operation category and continuously pass the database operation statement. The continuous ExecuteupDate and ExecuteQuery are then read the result set, and then the link is turned off. And the database is a relational database, and when Java is developed, it is an object model. The conversion of the relationship-object also makes people very headache. In enterprise development, the most headache is to replace the database. If the early demand analysis is not in place, it means the embarrassment that the project must be re -entered.
The Hibernate framework provides a built -in method. A simple Save Merge Delete Find method can achieve a lot of encoding functions that can be implemented in the past, and automatically encapsulate the value into JavaBean for easy use. And we don't have to care, when will we open the database link and when to close the database link. And Hibernate also provides the function of database switching. Simple configuration is sufficient, which is very convenient. There is no need to write a tedious SQL statement.
As for Spring, it can really be said to be the spring of Java developers. Rod Johson In 2002, in the book "Expert One to One J2ee Design and Development", he questioned the various status quo of the Java EE orthodox frame bloated, inefficient, and out of reality. Practical experience has analyzed and negated EJB's various bulky structures one by one, and replaced them in a simple and practical way. [My Java teacher and me at the time: at that time, the industry always shouted: "No EJB is developed by J2EE. And EJB's development is not understandable by ordinary people (Note: Just quote, I have not studied EJB, so I don’t have studied it, so I don’t study it, so I don’t study it. "
In simple terms, Spring is a lightweight control reversal (IOC) and a container framework for cut -oriented (AOP). IOC can also be understood as dependent injection. That is, the dependence between programs is given to Spring to manage, reducing the coupling between programs. In the program, we only need to inject a certain object into the object in the way of attributes. There is no need to say an example. The instantiated things are managed by Spring. As for the real object to be implemented, it can be configured in the configuration file. Of course, these objects must be followed by a certain specification. AOP is facing cut -faced programming, and Spring's declarative transaction is achieved through AOP. If you want to add transactions to the method in Hibernate, we need to care about who, where to add, and where to add, but after using declarative transactions, we do not need to related these details. Everything is given to Spring for processing.
The common characteristics of these three frameworks are: they are all lightweight and are flexible.
I just simply said it. In fact, there are many things worth studying, rather than one or two sentences.
It should also be explained that Spring is not responsible for the business layer, but integrates the "cut surface" scattered in the system to centrally manage, so that our programmers can have more energy to focus on the development of the business layer and speed up software to speed up software Development progress.
The above is all the contents of this article. You can refer to the friends who need it.