Struts Quick Start (1)

zhaozj2021-02-11  205

Struts Quick Start: What can it do? How do it do?

This article is selected from the fourth chapter of "Practical J2EE Application Architecture", the author is Nadir Gulzar, and is published by McGraw-Hill / Osborne Media (www.osborne.com) in March 2003

Published on theServerside.com

NOVEMBER 4, 2002

Posted in THSERVERSIDE.COM

November 4, 2002

Introduction

The goal of this article is to introduce the biggest advantage of Struts for expected Struts, and simultaneously illustrate its configuration and method of use. We will define a fully expressing architecture and discuss how to implement these needs in the Struts architecture. We also explore the semantics of the design pattern implemented in Struts, namely the semantics of the controller and related auxiliary components. These knowledge will play a role when designing components that are interacting with the architecture, and this is also necessary to expand the framework to suit a special requirement for a project. This article has complement information provided by http://jakarta.apache.org/struts.

MVC structure

The MVC structure is a method of breaking an application system to three parts (models, views, controllers). Originally applied to graphical user interface (GUI) loss, processing, and output model

Figure

Slightly, see the original book map.

model

The model represents the data of an application system and contains logic to access and manage the data. All data that belong to the persistent status of the application system should be saved in the model of the model. The service provided by the model must be sufficiently adequate to different terminals. Through a list of public methods of roughness, it should be easily understood how to control the behavior of the model. A model aggregates relevant data and operations to provide a detailed and accurate service; these packaging and abstract transaction function in operation is modeled. The interface of a model provides access and updating the model state, performing a method of executing complex processes in the model. The model service is accessed by the controller, used to query or make the status of the model changes. When the status changes, the model will notify the view.

view

The responsibility of the view is the state of the expression model. The presentation statement is packaged in the view, so the model data can be suitable for a variety of different terminals. When the changes in the model are conveyed to the view, the view will modify yourself. The view passes the user input to the controller.

Controller

The task of the controller is to obtain and translate the user input to the action and executed by the model. The task of the controller also selects the next view according to user input and execution results. In an J2EE-based application, the MVC structure is used to separate the character layer functionality represented by JavaBeans or EJB and the performance layer represented by JSP, and the intermediate via the servlet-based controller. However, the controller design must be used for the input of various types of terminals, including HTTP requests from the web terminal, WML, supplier and business partners based on XML-based documentation, and more. For HTTP requests and task paraduses, the submitted HTTP request is sent to a control center, interpreted and delegated to the appropriate request processor. This is also used as a second type of MVC structure. The request processor combines the architecture provided by the developer to implement a request for specific logic associated with the model. Relying on this interaction result, the controller can determine the next view to produce an appropriate reaction.

Struts MVC Semantics

We started from the key Struts abstraction, this is the core of its MVC architecture. Struts implements MVC mode using the Service to Worker mode. [Core]

(to be continued..)

Ice cloud translation, please let us know.

IceCloud@sina.com

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

New Post(0)