Overview of Java's struts2 framework

  • 2020-05-26 08:21:30
  • OfStack

1. Framework concept of struts2

The Struts2 framework is a lightweight MVC process framework, which means that the code of the program is not too much, and the resources taken up by the runtime are not too much. The MVC process framework means that it is a framework that supports layered development and controls the flow of data, such as where to come from, where to go, how to come and how to go. Struts2 is an Web application framework based on the MVC design pattern, which is essentially equivalent to an servlet. In the MVC design pattern, Struts2 ACTS as a controller (Controller) to establish the data interaction between the model and the view.

2. Advantages and disadvantages of struts2 framework

1, the advantages of

a) implements the MVC pattern with a clear hierarchy that allows programmers to focus only on the implementation of the business logic. b) rich tag library, greatly improve the efficiency of development. c) Struts2 provides a rich implementation of interceptors (d) through the configuration file, you can grasp the relationship between the various parts of the whole system. e) exception handling mechanism. You only need to configure the mapping of the exception in the configuration file to handle the exception accordingly. f)Struts2 has high scalability. The core jar package of Struts2 consists of one struts-default.xml file, in which some default bean,resultType types, default interceptor stack, etc., are set. All of these default Settings can be changed by the user using the configuration file, which can be changed to the bean, resulttype, etc. As a result, users who have developed plug-ins can easily use the plug-able features of the Struts2 framework with very simple configuration. The idea of faceted programming is also well represented in Strut2. The most important manifestation is the use of interceptors, which are small functional units of one by one. Users can combine these interceptors into one large interceptor. This composite interceptor is just like a single interceptor 1, as long as it is configured into one action.

2 and disadvantages

a) in Struts2, Action still has some trouble getting the parameters from jsp. The Getter and Setter methods can be configured for properties in Struts2's Action, and request parameters can be set to these properties by default interceptors. In this way, when the request parameters are large, the Action class becomes bloated with these form properties, which can feel confusing. There are also properties in Action that can be used not only to get request parameters but also to output them to jsp, which is even messier.


Related articles: