WEB开发网
开发学院WEB开发Jsp Sunil Patil 告诉你如何扩展Struts 阅读

Sunil Patil 告诉你如何扩展Struts

 2008-01-05 20:12:53 来源:WEB开发网   
核心提示: by Sunil Patil11/10/2004 IntrodUCtionI have seen lot of PRojects where the developers implemented a proprietary MVC framework, not because they wanted to do so

 by Sunil Patil
11/10/2004

IntrodUCtion

I have seen lot of PRojects where the developers implemented a proprietary MVC framework, not because they wanted to do something fundamentally different from Struts, but because they were not aware of how to extend Struts. You can get total control by developing your own MVC framework, but it also means you have to commit a lot of resources to it, something that may not be possible in projects with tight schedules.

Struts is not only a very powerful framework, but also very extensible. You can extend Struts in three ways.

  1. PlugIn: Create your own PlugIn class if you want to execute some business logic at application startup or shutdown.
  2. RequestProcessor: Create your own RequestProcessor if you want to execute some business logic at a particular point during the request-processing phase. For example, you might extend RequestProcessor to check that the user is logged in and he has one of the roles to execute a particular action before executing every request.
  3. ActionServlet: You can extend the ActionServlet class if you want to execute your business logic at either application startup or shutdown, or during request processing. But you should use it only in cases where neither PlugIn nor RequestProcessor is able to fulfill your requirement.

In this article, we will use a sample Struts application to demonstrate how to extend Struts using each of these three approaches. Downloadable sample code for each is available below in the Resources section at the end of this article. Two of the most successful examples of Struts extensions are the Struts Validation framework and the Tiles framework.


Tags:Sunil Patil 告诉

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接