Struts principle and application (1)

zhaozj2021-02-11  195

This article is a speech outline of 俺 at the company's technical conference

Is it a small tutorial.

Struts Principles and Applications December 1, 2003

Chapter 1: MVC Architecture

Introduce Struts' Theoretical Foundation, MVC Architecture

Chapter 2: J2EE N-TIERS STRUCTURE

Introduction J2EE's N-layer structure and position in Struts

Chapter 3: Struts Configuration

Struts basic installation instructions

Chapter 4: EXAMPLE 1: Basic Framework

One of the simplest examples, used to familiarize themselves with the basic usage of Struts

Chapter 5: Struts Work Flow

Introduction Struts workflow

Chapter 6: EXAMPLE 2: Login Application

The Struts is provided, simple landing programs.

Chapter 7: Taglib and Other Skills

Introduce the application of Taglib in Struts, as well as other related features

Chapter 8: Other Web Framework

Comparison between Struts with other framework

Chapter 1: MVC Architecture

Struts PrinciPle and Practice Model - View-Controller (MVC) is a software design pattern that appears in the 80s SmallTalk-80, which is now widely used.

1 Model (Model) model is the main part of the application. The model represents business data, or the business logic .2 View (View) view is part of the user interface in the application, which is the interface that the user has interactively interacts.

3 Controller The controller work is based on the user's input, controls the user interface data display and update the Model object state.

The appearance of the MVC not only implements the separation of the functional module and the display module, but it also improves the needableness, scalability, portability, and components of the application system.

In the early procedures, if you don't pay attention to logarithmic functions and decoupling, it is often caused by the complexity and difficulty maintenance of the program. A lot of VB, Delphi and other RAD programs have this problem. Even now C #, Java sometimes occurs in the phenomenon of writing business logic in display module

The tube MVC design mode has been put forward very early, but the introduction of MVC in the development of a web project is difficult. Main reason: First, in the development of early Web projects, the separation of programming language and HTML has been difficult to implement. The CGI program generates HTML content as a string output. Later, as the scripting language appeared, the previous way was fell over, and it was changed to embedded the script language to the HTML content. These two ways have an identical shortcomings, that is, they can always separate program languages ​​and HTML. Second, the function of the scripting language is relatively weak, lacks some necessary technical foundations for supporting MVC design patterns. It is only changed until J2EE-based JSP Model 2 has been introduced. It uses JSP technology to implement view features, with servlet technology to implement controller's function, use JavaBean technology to implement model function

JSP Model 1 with JSP Model 2

SUN has developed two specifications early in JSP, called Model1 and Model2. Although Model2 achieves MVC to a certain extent, its application is not satisfactory

JSP Model 1

JSP Model 2

Model2 is easy to make multiple Controller, and more complicated to page navigation

Some people think that Model2 is still not good enough, so Craig R. McClanahan submitted a web framework to java community in May 2000. This is the later struts.

In July 2001, Struts1.0 was officially released. The project has also become one of the Struts of Apache Jakarta's subproject is an MVC architecture implemented on the basis of Model2. It has only one central controller, and he uses XML customized URL. Use action to handle logic

Chapter 2: J2EE N-TIERS STRUCTURE

Struts PrinciPle and Practice Early network system design often uses a three-layer structure. The most common structure is the presentation layer, a domain layer, and an infractions (Infrastructure).

The n-layer structure is proposed in order to adapt to the current B / S mode development Web Application needs. The traditional Brown model refers to: representation, control / intermedler / mediator, domain layer (DOMAIN), data mapping, and data source layer (DATA SOURCE). It is actually an increase in two intermediate layers in the three-layer architecture. The control / intermediary layer is located between the representation layer and the domain layer, and the data mapping layer is located between the domain layer and the infrastructure layer.

The J2EE specification proposes its own N-Tiers structure.

The following table is a comparison of several models.

ISA Brown J2EE layer correspondence part represents layer representation layer client browser HTML page, XSL, mobile client, etc. Server representation layer JSP and ActionForm, XML control / intermediary layer Controller controller and Action domain field layer Layer Layer business layer JavaBeans / sessionBean / Session facade data mapping layer integrated layer EntityBean / jdo / hibernate / jdbc data layer data source resource layer RDBMS database

One of the basic principles of J2EE is to make the implementation of each layer to unlock or coupling minimization. Final implementation can be arbitrarily switched to switch to a layer.

For example, in the data mapping layer, EJB's BMP, CMP can be used, and Hibernate et al. O / RMApping, or JDO. This is determined by the deployed environment.

转载请注明原文地址:https://www.9cbs.com/read-4966.html

New Post(0)