Struts2-generation history step by step
Struts2 step by step generation History 1 JSP:
In earlier web applications, html static pages were used. jsp embedded java scripts in HTML files to achieve page dynamics. HTML tags are used to layout and display the appearance. Java code is responsible for extracting dynamic data and implementing business logic. For simple applications, this method can simplify development difficulty and speed up development, but it also brings problems. For large projects, a large number of html and java code are mixed together, as a result, the page display logic and business logic are chaotic, which is difficult to maintain due to poor code readability.
To separate the display and business logic, sun has developed two jsp development modes: model1 and model2.
2 model1:
Use jsp and javabean technology to separate page display from business logic. Jsp is responsible for page display. If you want to submit requests for javabeans, javabeans are used to implement business logic and process data.
It is not hard to see that jsp is responsible for processing the request and returning the processing result. All data is processed by javabeans, and jsp displays the data. However, it also has drawbacks. For large application systems, a large number of java statements on the page mix the page logic with the business logic, which is not easy to understand and maintain.
3 model2
In model1, the jsp page is embedded with the process control code and part of the logic processing code. Extract the code and place it in a separate role. This role is the Controller role, this web architecture is model2. Model2 conforms to the mvc Architecture Pattern <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + pgltzybzcm9 "http://img.blog.csdn.net/20150330205700234" alt = "\">
The Servlet acts as the controller. It accepts the request and distributes the request information to the jsp page of the shadow to generate a response. The Servlet controller also generates javabeans instances based on the requirements of the jsp view and outputs them to the jsp. With model2's high-price purchase, you can separate page display, business logic processing, and process control from clear ones. jsp is responsible for data display, javabeans is responsible for processing data and business logic, and servlet is responsible for process control. Front-end page designers and back-end java developers develop simultaneously without interfering with each other.
4. web framework-struts is a web application developed based on the mvc Architecture. It is easy to have multiple controllers. When writing controllers, page navigation is also complicated. By analyzing web applications based on the mvc framework. Same: (1) All requests access the controller directly, and the controller distributes the requests. (2) The Controller instantiates a javabean object, which processes business logic and data. (3) The Controller presents a View to the user based on the request processing result. Different: (1) different processing units are applied to different user request URLs (2) data submitted by different forms must be stored by different javabean objects (3) different request processing results lead to different views presented to users by controllers. Based on these differences, you can develop a web software that implements the entire calling process according to the mvc Architecture and uses external configuration files to solve the problems that need to be changed. With this flexible configuration method, you can develop web software into a platform for other developers to use. The web framework was born. Using web frameworks reduces the burden on developing web applications, improves development efficiency, and reduces maintenance costs. There are many web frameworks, such as Struts, WebWork, Spring MVC, Tapestry, JSF, and WebPage3.0. Later, we will continue to introduce the struts framework.
4.1 struts1
4.1.1 struts1 structure:
Components: Call the business component method to complete the business logic, which can be compiled by developers. The struts1 framework provides the action base class. We need to inherit the action base class when writing the Action class.
(2) Model
The model consists of two parts: the form bean object specified by the struts1 framework, which stores the submitted form data. Another part is the business component class written by developers for the business logic of the system.
(3) view
The struts1 framework supports JSTL, JSF, and XSLT.
4.1.2 disadvantage 1 actionform: difficulty in Unit 2 testing
4.2 struts2.
Summary:
According to the generation of struts2, the emergence of a framework and the emergence and development of technology are all driven by demands and problems existing in existing technologies.