文档详情

毕业论文外文翻译Strts 开发的最佳实践.doc

发布:2018-09-04约1.86万字共12页下载文档
文本预览下载声明
Best practices for Struts development Palaniyappan Thiagarajan, Pagadala Suresh Struts: A brief introduction Struts, an open source framework you can use to build Web applications, is based on the popular Model-View-Controller (MVC2) design paradigm. The framework is built upon standard technologies like Java Servlets, JavaBeans, ResourceBundles, and XML, and it provides flexible and extensible components. Struts implements the Controller layer in the form of?ActionServlet?and recommends building the View layer using JSP tag libraries. Struts also provides a wrapper around the Model layer throughAction?classes. Figure 1 illustrates the Struts framework based on the Model-View-Controller design. Figure 1. Struts and MVC ? Overview of Struts components First, well explain the Struts components in the context of best practices and the role each one plays in your Web application development. Action Every?Action?of your application extends Struts?org.apache.struts.action.Action. These?Action?classes provide an interface to the applications Model layer, acting as a wrapper around the business logic. Each?Action?class must provide its case-specific implementation to the?perform()?method. The?perform()?method always returns a value of type?ActionForward. ActionForm Every?ActionForm?of your application extends Struts?org.apache.struts.action.ActionForm.?ActionForms are simple JavaBeans that encapsulate and validate request parameters. To validate your request data, your?ActionForms?validate()?method must give a case-specific implementation.?ActionForms serve as a carrier of request data to the?Action?class. A JSP object combines with a respective?ActionForm?to form your applications View layer, where almost every form field of the JSP object maps to an attribute of the corresponding?ActionForm. JSP custom tag libraries The JSP custom tag libraries are a collection of actions presented as tags. This is a powerful feature of the JSP Specification 1.1; it allows you to separa
显示全部
相似文档