Application of Web Program Development Based on Struts Framework

As we all know, Struts framework based on the MVC design pattern is one of the most widely used frameworks for Web development nowadays to improving the code reusability and flexibility, which separates the display and logic in Web application and development. This paper first analyzes the Struts framework and its implementation of model, view and controller layers, then summarizes the advantages and disadvantages of Struts framework. Meanwhile, some details should be paid attention to during development.


Introduction
MVC is a design pattern that forces the separation of application input, processing, and output. The applications of MVC are divided into three core components: a model, a view, and a controller, and each handles its own task. This framework uses the idea of software layering, so it separates the presentation, control and logic layers of the software. In this way, each layer does its own work to avoid the maintenance and modification difficulties that were caused by the integration of the functions in previous software development.

Struts structure
Struts is an open source project of the Apache organization and one of the most popular MVC architectures, also, it is a new generation of Web frame developed on the basis of MVC pattern. With its support, we can quickly develop web-based applications and improve the layered application of MVC. The tag library of Struts has powerful page development capabilities yet. The processing flow of Struts framework clearly reflects the characteristics of MVC system, and the simple Struts component structure is shown in figure 1.
Once the client side makes an HTTP request, the request is received by the Struts controller immediately. In fact, it is a servlet, whose name is ActionServlet in Struts. In the struts-config.xml configuration file, there is a valid mapping for ActionServlet, and the mapping will be delivered to the Action handler object for processing, what's more, we should fill in any Form you have before handing it over. Remember that a Form is a Java class that records the same information as the properties and contents submitted by the HTTP Form, The Action handler object can access the data in the Form, process and respond to customer's requests, and it can also invoke the Bean components that encapsulate the concrete business logic in the background. The Action handler object notifies the controller based on the result of processing, then the controller sends the result of the processing to the view layer for display. As an MVC framework, Struts provides implementation components for Model, View, and Controller. Model: The Model section provides Action and ActionForm objects, The ActionForm object guarantees the interface between the Model and View in Struts as all Action handler objects derive from the Action class. The Action handler object encapsulates the concrete processing logic, thus it can invoke the business logic module and submit the response to the appropriate View component. ActionForm component objects provided by Struts can describe client form data by defining properties. Therefore, developers can subclass objects from it. In combination with the custom tag library provided by Struts, you can achieve good encapsulation and support of the form data on the client side. The Action processor object can read and write to it directly instead of interacting with the Request or Response object, meanwhile, Struts can use O/R mapping or EJB components to realize the development of the business logic layer according to the complexity of the system. View: The View part of Struts is implemented through JSP technology. Struts framework provides a library of custom tags that allow you to interact with the Model part of the system. The created JSP form not only implements the mapping to the ActionForm in the Model section, but also completes the encapsulation of data, while the custom tag also provides maximum flexibility.
Controller: It consists of the core class of ActionServlet, which receives the request from the client and gives it to the RequestProcessor class. There is also an ActionMapping object class in the Controller in Struts. The Servlet includes a set of configurable AcfionMapping objects, each of which implements the mapping of a request to an Action handler object in a specific Model section.

Application of Struts in Web development
Struts structure is very suitable for the development of large and complex systems, so there are the following methods for the development of WEB applications.
Implementation of the view layer: The JSP page is presented to users by the view layer, respectively achieved by their own definition of the JSP page. The content of the Struts framework's tag library can be used in the implementation of the page. When design the view layer, we should notice that the HTTP submission and the Action receiving are codes in ISO-8859-1, and what we present to users is the internationalized code, which should be translated for display and processing.
Implementation of the control layer: The main task of the control layer is to receive and intercept user's requests, map the received requests to the corresponding Action class, and invoke the model component to execute the corresponding business logic. Thus, it can get the result of the execution of the business logic. In this way, we can select the appropriate view component to users. The design of control layer should realize the specific function by inheriting the Action class. Action class is written in a singleton mode, so you generally cannot use the previous code, for example, there is some thread insecurity associated with it when assigns a value to a static variable, here, the Action class mainly invokes the corresponding JavaBean class or EJB component, while these components implement operations on the database.

</action-mapping>
The entire logical flow of the system is contained in struts-config.XML, which is a hierarchical XML file, and during initialization the ActionServlet reads the information from it. The XML file is an illustrative document, which makes it easy for the developer to understand and view the flow of the application without having to recompile the code after the flow changes.

Conclusion
The Struts framework based on MVC pattern separates the page layer from the logic layer, which reduces the coupling between each layer and improves the reusability, flexibility and maintainability of the system. Programing the Web system with Struts framework can show the superiority of Struts framework, meanwhile, it makes the development process of software clearer and more efficient.