Introduction:
In many projects, developers implement their own MVC framework, not because they want to do something fundamentally different from Struts, but because they are not aware of how to expand Struts. Developing Your Own MVC framework can gain full control, but it also requires a lot of resources to implement it (human and material resources). Sometimes this is impossible under a tight schedule.
Struts is not only a powerful framework, but also scalable. You can expand Struts in three ways.
1. PlugIn: If you want to do some business logic during application startup or shutdown, create your own PlugIn class.
2. RequestProcessor: If you want to make some business logic at a certain time point in the request processing process, create your own RequestProcessor class. For example, before each request is executed, you can extend RequestProcessor to check whether the user has logged in and whether he has the permission to execute a specific action.
3. ActionServlet: If you want to perform some business logic during application startup and shutdown and when the request is processed, you can also expand the ActionServlet class. However, you should use ActionServlet when PlugIn and RequestProcessor cannot solve your needs.
In this article, we will use a Struts application example to demonstrate how to use these three methods to expand Struts. The sample code can be downloaded from http://www.onjava.com/onjava/2004/11/10/examples/sample1.zip. Two successful examples of Struts extension are Struts's Validation and Tiles framework.
Let's assume that you are familiar with the Struts framework and know how to use it to create a simple application. If you want to know