Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the Struts framework and its components

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article analyzes "what is the Struts framework and its components". The content is detailed and easy to understand. Friends who are interested in "what is the Struts framework and its components" can follow the editor's train of thought to read it in depth. I hope it will be helpful to you after reading. Let's learn more about "what the Struts framework and its components are" with the editor.

First, what is a framework?

A framework is a set of reusable components that provide a unified set of interfaces and programming methods, and we can extend our own specific logic in the framework.

Second, MVC design pattern

The application is divided into three parts: model Model, view View, controller Controller; model components: responsible for business logic; the model contains the core functions of the application. The model encapsulates the state of the application. Sometimes the function it contains is status. It knows nothing about views or controllers. View component: a view that represents the scope of the business; the view provides a representation of the model. It is the appearance of the application. The view can access the read method of the model, but not the write method. Besides, it knows nothing about the controller. The view should be notified when the model is changed. Controller component: responsible for controlling the flow and status of user input; the controller responds to user input. It creates and sets up the model. Struts, which is an MVC implementation using servlet and JavaServer Pages technology; a project organized by Struts,Apache, an open source implementation of MVC

Third, what is the Struts framework

Struts is a reusable MVC 2 design made up of a set of collaborative classes, servlet, and JSP tags. This definition indicates that Struts is a framework, not a library, but the Struts framework also contains rich tag libraries and utility classes that work independently of the framework.

Fourth, Overview of Struts

1Jing client browser creates an event for each HTTP request from the client browser. The Web container will respond with a HTTP response.

The controller receives the request from the browser and decides where to send the request. As far as Struts is concerned, the controller is a command design pattern implemented in servlet. The struts-config.xml file configures controller commands.

3. Business logic updates the state of the model and helps control the flow of the application. In the case of Struts, this is done through the Action class, which is "thin" wrapped as the actual business logic.

4The state model of the model represents the state of the application. The business object updates the status of the application. ActionForm bean represents the state of the model at the session or request level, not at the persistence level. The JSP file uses the JSP tag to read information from the ActionForm bean.

The 5Jing View view is a JSP file. There is no process logic, no business logic, no model information-- only tags. Tags are one of the factors that distinguish Struts from other frameworks, such as Velocity.

Fifth, Controller (controller) in Struts

Implementation of the command design pattern: Struts's controller maps events (usually HTTP post) to a servlet of the class.

ActionServlet (Command) creates and uses Action, ActionForm, and ActionForward. Configure the Command through the struts-config.xml file. Thus extending Action and ActionForm to solve specific problems. You can add Command functionality by extending ActionServlet.

In the Struts framework, the controller component consists of three parts:

The main contents are as follows: 1, the message control module; all the user's submission requests are sent to the message control module, and the message processing module is found by the message bus module according to the view mapping module to execute the processing logic. The message control module receives requests from all users and finds and processes them according to the request view. This is done through the ActionServlet and RequestProcessor classes in Strtus.

2, message processing module; this module performs the logical processing of the message, so it is usually implemented by the user extension. It is implemented through the Action class in Struts.

3, the view mapping module; the combination of controller logic and view logic is to establish its link through the configuration module and configuration file. The configuration module in Struts is completed by the ModuleConfig class, and the configuration file is provided by the struts-config.xml file.

6. View in Struts (View)

The view component is implemented through the JSP component. The Struts framework extends and encapsulates the view components. Struts's extension to the view provides a set of extension server tags to provide view display and pass data to processing buffers, which are implemented by ActionForm's extension classes.

The Struts framework uses ActionForm Bean to implement the interaction of data between the view and the controller and to maintain the state of the session-level or request-level model.

Server tags mainly include:

Html view tags Logic logic flow control tags Bean data buffers read tags

Seventh, Model in Struts (model)

1the Struts framework does not define specific model components, but it is up to users to choose reasonable model components. The model components available in J2EE include: JavaBean user-defined components; EJB components, implemented by the EJB container; JDO future J2EE data access model; and some extension frameworks such as Hibernate

2, the level of state in the model: session level or request level: ActionForm bean to maintain; persistence level: model components to maintain.

So much for sharing about the Struts framework and what its components are. I hope the above content can improve everyone. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report