Using struts to build MVC application

Source: Internet
Author: User
Tags advantage

This article describes how to use struts to build an MVC application.

Model 1 and Model 2 introduction

One of the concepts we often mention when developing Web applications is Model 1/model 2, so what exactly does it mean? In fact, it is a description of the different models that use JSP technology to form Web applications. The following is a brief introduction to this concept.

Model 1

In the case of using Java technology to build Web applications, because of the development of JSP technology, quickly this kind of easy to grasp and realize rapid development of technology is the main technology to create Web applications. JSP pages can be easily combined with business logic (Jsp:usebean), server-side processing (jsp:scriplet), and HTML (

Of course, this development model in the rapid and small-scale application development, there is a very big advantage, but from the point of view of engineering, it also has some deficiencies:

The implementation of the application is generally based on the process, a set of JSP pages to implement a business process, if you want to make changes, must be modified in several places. This is very detrimental to application extensions and updates.

Since applications are not built on modules, business logic and presentation logic are mixed in JSP pages without abstraction and separation. So it is very unfavorable to reuse and change of application system business.

Considering these problems, you have to adopt different design patterns when developing large Web applications-this is Model2

Model 2

Model 2 represents a framework based on the MVC pattern. MVC is a shorthand for model-view-controller. "Model" represents the Applied business logic (implemented through the JAVABEAN,EJB component), "View" is the representation of the application (generated by the JSP page), and "Controller" is the process control (typically a servlet) that provides the application. This design model divides the application logic, the processing process and the display logic into different component implementations. These components can be used for interaction and reuse. Thus making up for the model 1 of the deficiencies.

Model 2 has the advantage of being modular to make it easier to develop and manage large-scale systems, but developing an MVC system is much more complicated than simple JSP development, which requires more time to learn and master. At the same time, the introduction of new things brings new problems (which reminds me of an article on "Automatic Computing", which mentions a higher degree of complexity in order to reduce the complexity of the system).

You must rethink and design the application structure based on the MVC component. The application that can be realized by building a simple JSP page now becomes the design and implementation process of several steps.

All pages and components must be implemented in the MVC framework, so additional development work is required.

MVC itself is a very complex system, so using MVC to implement Web applications, it is best to choose a ready-made MVC framework, under which to develop, so as to achieve a multiplier effect. There are a lot of MVC frameworks available now, because struts has a complete document and is relatively simple, so it's easier to develop an MVC system with it.

A brief introduction to the structure and processing process of struts

Struts is a project of the Apache organization, like other Apache projects, it is also an open source project. Struts is a better MVC framework that provides low-level support for developing MVC systems, with the main technology being the servlet,jsp and custom tag library. Access to its use version and specific information can be found on the http://jakarta.apache.org Web site.

The basic composition of the struts framework is shown in the following illustration:

Figure 1 Struts UML diagram

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.