What's the difference between sprng and struts? _java

Source: Internet
Author: User
Tags aop object model

Spring

1) Open source framework

2 IoC (Control reversal), the creation and dependencies of the class are written in the configuration file, injected by the configuration file, to achieve the loose coupling

3 AOP will be safe, transaction equals program logic relatively independent function extraction, using spring's configuration file to plug these functions, to achieve the following aspects of programming, improve the reusability

What is the difference between struts and spring?

Structs: Like WW2, is a typical MVC framework, structs emphasis on the performance layer, its own role as a controller controller, it can be a good performance layer and business layer separated. Spring: Plainly is a hodgepodge that provides the integration of the current various popular frameworks, classic hibernate integration, and, in addition, Mail,axis ... There are all kinds. In addition, it is more classic is the IOC and AOP functions. In addition, it provides spring MVC, which is based on Webflow. Spring is a synthesis of a series of web framework technologies, which are characterized by lightweight, non-intrusive, decoupled design, and so on. The most commonly used is its ioc/di, that is, inversion control/dependency injection, such as XML declaration bean, Run-time injection.

I don't understand well because I don't understand it very well.

Simply put the struts spring hibernate these 3 mainstream open source, the industry's de facto standard framework!

In the early days when there was no struts, we passed data in front and back, using scoped objects (Page,request,session,application), which contained a large number of getparameter and getattribute, and conversions of data types. Wasted a lot of time. And a lot of development has not used the MVC pattern, increased the later maintenance and two times the difficulty of development.

In this case, struts came into being, he provided three components for our use, before and after the database transfer using Actionform to pass, directly packaged into objects. Easy to operate. Moreover, as a typical implementation of MVC, the separation of view and control layer makes the code clearer and easier to maintain.

Early to do JDBC operation, I believe that we all have such experience, write their own database operation classes, the continuous transfer of database operations statements, executeupdate and ExecuteQuery and then loop read the result set, and then close the link. And the database is relational database, and Java development, is the object model, the relationship-object conversion, also makes people very headache. In the enterprise development, the most headaches is the replacement of the database, if the initial requirements analysis is not in place, it means that the project will be a new embarrassment.

Hibernate framework, provides a built-in method, simple save Merge Delete Find method, you can realize the previous need for a lot of code to achieve the function, and the value automatically encapsulated into the JavaBean, easy to use. And we don't have to care, when to open the database link, when to close the database link. And hibernate also provides the function of the database switch, simple configuration can, very convenient. You don't have to write a cumbersome SQL statement.

As for spring, it can really be said that Java developers in the spring. In a book called "Expert One to one" and development in 2002, Rod Johson questions the state of the Java EE Orthodox Framework, which is bloated, inefficient, and divorced from reality, Based on his many years of practical experience, the author analyzes and negates the various unwieldy structures of EJB, and replaces them in a concise and practical way respectively. "My Java teacher and I were there: at that time, the industry has been shouting:" No EJB is Java EE development. and the development of EJB is not common people can understand (note: Just quote, I have not studied EJB, so dare not to raved!) )”】

In short, spring is a lightweight control reversal (IoC) and aspect-oriented (AOP) container framework. IOC can also be understood as dependency injection. Is that the dependencies between programs are given to spring to manage, reducing the coupling between programs. In a program, we simply inject an object into the object as a property, without an instance, and the instantiated thing is managed by spring. As for the implementation of the Interface, you can configure it in the configuration file, which, of course, must be followed by a specification (in the same way). AOP-oriented programming, spring's declarative transaction is the implementation of the dope through AOP. In hibernate, if we want to add business to a method, we need to be concerned about who we add, where we add it, and when we use declarative transactions, we do not need to relate to these specifics. Let spring handle everything.

The common features of these three frameworks are that they are lightweight and flexible to use.

I am here to simply say a little bit, in fact, a lot of things are worth our research, not one or two words can be summed up.

Also to explain is that spring is not responsible for the business layer, but the system scattered in the "slice" together, centralized management, so that we programmers have more energy to focus on the development of the business layer, accelerate the development of software.

The above mentioned is the entire content of this article, the need for small partners can refer to.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.