Java Web framework: Struts2 Introduction

Source: Internet
Author: User

History


Struts history. JSP has undergone JSPModel1 and JSPModel2 stages. JSPModel1 just like PHP today, each file is mixed with business logic and HTML code, and each JSP interacts directly with the database. This model is very limited and has poor code reuse. Later, an improved version of JSPModel1 is added, which adds JavaBean. JSP files need to access the database indirectly through JavaBean. There are three techniques used in JSPModel2: Servlet, JavaBean, JSP. The servlet acts as a controller, takes control of the process, dispatches requests, and invokes JavaBean and JSPs. JavaBean is responsible for interacting with the database. JSP only does the display of pages, which is used to generate dynamic Web pages. JSPModel2 has begun to show the idea of MVC.


Brief introduction


Struts is a web framework, and the problem that the web framework needs to address is the HTTP stateless and text-based two issues. Resolving stateless issues can be managed through a cookie or session, both of which have been resolved in the servlet. Text-based issues are issues that struts should focus on. HTTP is a text protocol, which is a tedious process to convert to data structures in Java and method invocations. With the struts framework, these tedious things do not need to be dealt with on their own.


STRUTS2 is not a framework for improvement on the basis of STRUTS1, but a new framework based on WebWork. But if you are already familiar with Struts1, then Struts2 learning is very easy.


The MVC in struts. The controller is Filterdispatcher, also known as the front-end controller, because it receives the request first. Its essence is a servlet that allows Struts2 to operate as long as it is configured to flow HTTP requests to Filterdispatcher. In the latest version of Struts, Filterdispatcher has been renamed Strutsprepareandexecutefilter, with a clearer name. The model (action) is a model of the thing itself, the business logic, the data storage should be put in the models. A view is a result, something the client can see. The Web container first finds the XML, and the developer first assigns the Filterdispatcher to XML, which allows struts to execute it.


The entire workflow for STRUTS2 is as follows:

It looks very concise, and the entire struts framework needs to know what the above is all about.

Java Web framework: Struts2 Introduction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.