Common Web _MVC Framework _ Introduction

Source: Internet
Author: User
Tags html tags java web
   The Web-based MVC framework is an unprecedented boom in the world of Java EE. A new MVC framework is released on the TTS site almost every two weeks. At present, the better MVC, the veteran has struts, webwork. The emerging MVC framework has spring MVC, Tapestry, JSF, and so on. These are mostly works of the famous team, and there are also some fringe team works, such as Dinamica, Vraptor and so on. These frameworks provide a good level of separation capability.

  On the basis of good MVC separation, some ready-made auxiliary class libraries are provided, and productivity is improved. How to choose a good framework to apply in your project will be critical to the efficiency and reusability of your project.

  This article introduces two of the most popular and commonly used frameworks. Struts struts is part of the Jakarta Project under the Apache Software Foundation. The main architectural design and developer of the Struts framework is Craig R.mcclanahan. Struts is the undisputed king of the current Java WEB MVC framework. After more than five years of development, struts has grown into a stable, mature framework, and occupies the largest market share in the MVC framework. But some of struts's technical features have lagged behind the emerging MVC framework. With spring MVC, Webwork2 these more sophisticated, more scalable frameworks, struts has been challenged as never before.

  But in terms of product development, struts is still the surest choice. Struts has a set of mutually collaborative classes (components), Serlvet, and JSP tag lib. The Web application based on struts architecture basically conforms to the design standard of JSP Model2, which can be said to be a type of change of MVC design pattern. Based on the description of the framework, we can easily understand why struts is a web framwork, not just a combination of some tag libraries. But Struts also contains a wealth of tag libraries and utility classes that work independently of the framework. Struts has its own controller, and incorporates other technologies to implement the model and view layers (views). At the model level, struts can be easily combined with data access techniques, including EJB,JDBC and object Relation Bridge.

  In the view layer, struts is able to combine these presentation layer components with JSPs, Velocity templates,xsl, and so on. The body of StrutsThe structural struts framework is the embodiment of the MVC pattern, and below we look at the Struts Architecture (Architecture) from the model, view, and control separately. The view is primarily built from a JSP, and struts itself contains a set of extensible custom Tag libraries (TAGLIB) that simplifies the process of creating a user interface. Currently includes: Bean tags,html tags,logic tags,nested tags,template Tags these several taglib. For more information about them, refer to the Struts user manual The model model is primarily a representation of the state of a system (sometimes, business logic operations that change the state of the system are also partitioned into the model). In struts, the state of the system is mainly actiomform bean, in general, these States are non-persistent. If these States need to be converted to persistent data storage, struts itself provides utitle packages that can be conveniently associated with database operations from the controller perspective (Controllers) in the Struts framework, The controller is primarily Actionservlet, but the operation of the business logic is mostly coordinated by the action, actionmapping, Actionforward components (perhaps these components should be partitioned into the business logic in the model).
Where action acts as the true implementation of the business logic, while Actionmapping and Actionforward specify the direction in which different business logic or processes are run. For how struts controls and processes customer requests, let's specify the four core components of struts. These components are: Actionservlet.

  Action classes,action Mapping (here includes Actionforward), Actionfrom Bean. Spring Spring is actually a concrete implementation of the design ideas elaborated in the expert one-on-one. Development. In one-on-one, Rod Johnson advocates the design of the Java EE Pragmatism and provides a preliminary development framework implementation (INTERFACE21 development package) with the book. Spring is a more comprehensive and concrete embodiment of this idea. Rod Johnson developed in INTERFACE21On the basis of the package, it has been further transformed and expanded to a more open, clear, comprehensive and efficient development framework. Spring is an open-source framework that was created by Rod Johnson and described in his book, "The Java EE Design Development Programming Guide". It is created to address the complexities of enterprise application development. Spring makes it possible to use basic javabeans to accomplish things that were previously only possible by EJBS. However, the use of spring is not limited to server-side development.

  From the standpoint of simplicity, testability, and loose coupling, any Java application can benefit from spring. In simple terms, Spring is a lightweight control reversal and face-oriented container framework. Of course, this description is a little too simple. But it does outline what spring does. In order to better understand spring, let's analyze This description: 1, light weight, from the size and cost of the two aspects of spring is lightweight. The full spring framework can be published in a jar file with a size of more than 1MB. and the processing overhead required by spring is negligible. In addition, spring is non-intrusive: Typically, objects in spring applications do not depend on light weight?? Spring is lightweight both in terms of size and overhead. The full spring framework can be published in a jar file with a size of more than 1MB. and the processing overhead required by spring is negligible.

  In addition, spring is non-intrusive: Typically, objects in spring applications do not depend on a particular class of spring. 2, control reversal?? Spring facilitates loose coupling through a technique called inversion of Control (IoC). When IOC is applied, objects passively pass their dependencies instead of creating or locating dependent objects themselves. Can you think of the IOC as opposed to Jndi?? 

  Instead of objects looking for dependencies from a container, the container passes the dependency to it when the object is initialized without waiting for it to be requested. 3. Face the plane?? Spring includes rich support for aspect-oriented programming, allowing for the development of cohesive applications by separating the business logic of the application from the system services such as auditing and thing management. Apply objects only do what they should do?? Complete business logic?? That's all. 

  They are not responsible (or even conscious) for other system concerns, such as log or object support. 4, container?? Spring contains and manages the configuration and lifecycle of application objects, which in this sense is a container. You can configure how each of your beans is created?? Create a separate instance of your bean based on a configuration prototype, or generate a new instance every time you need it?? And how they relate to one another. However, spring should not be confused with the traditional weight of EJB containers, which are often bulky and bulky, are difficult to use. Framework: Spring makes it possible to configure and assemble complex applications from simple components. In spring, application objects are combined declaratively, typically in an XML file. 

  Spring also provides a number of basic functions (transaction management, persistence framework integration, and so on), leaving the development of application logic to you. All of these features of spring enable you to write cleaner, more manageable, and easier-to-test code.  They also provide the basis for various sub-frameworks in spring.

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.