Struts is the premier framework for building Java-based Web applications. Using the Model-View-Controller (MVC) design pattern, Struts solves many of the problems associated with developing high-performance, business-oriented Web applications that use Java servlets and JavaServer Pages. At the outset, it is important to understand that Struts is more than just a programming convenience. Struts has fundamentally reshaped the way that Web programmers think about and structure a Web application. It is a technology that no Web programmer can afford to ignore.
This chapter presents an overview of Struts, including the historical forces that drove its creation, the problems that it solves, and the importance of the Model-View-Controller architecture. Many of the topics introduced here are examined in detail by subsequent chapters.
What is MVC?
Model-View-Controller (MVC) is a design pattern put together to help control change.
MVC decouples interface from business logic and data.
Model: The model contains the core of the application's functionality.
The model encapsulates the state of the application.
Sometimes the only functionality it contains is state. It knows nothing about the view or controller.
View: The view provides the presentation of the model. It is the look of the application.
The view can access the model getters, but it has no knowledge of the setters.
In addition, it knows nothing about the controller. The view should be notified when changes to the model occur.
Controller: The controller reacts to the user input. It creates and sets the model.
No comments:
Post a Comment