Struts 开发的最佳实践(含外文出处)
Struts 开发的最佳实践(含外文出处)(中文1900字,英文1500字)
摘要:本文简要的介绍了Struts 作为一种开源框架,可用来构建 Web 应用程序,它基于流行的 Model-View-Controller (MVC2) 设计范型。该框架构建在一些标准的技术之上,比如 Java Servlets、JavaBeans、ResourceBundles 和 XML,并且可提供灵活和可扩展的组件。Struts 以ActionServlet 的形式实现了 Controller 层,并建议使用 JSP 标记库构建 View 层。Struts 通过 Action 类提供了围绕 Model 层的包装器。
关键字:Struts MVC 数据库实例 JavaBeans
BEST PRACTICES FOR STRUTS DEVELOPMENT
Palaniyappan Thiagarajan, Pagadala Suresh
Overview of Struts components
First, we'll 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 application's 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 ofyour application extends Struts' org.apache.struts.action.ActionForm. ActionForms are simple JavaBeans that encapsulate and validate request parameters. To validate your request data, your ActionForm's 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 application's View layer, where almost every form field of the JSP object maps to an attribute of the corresponding ActionForm. [资料来源:Doc163.com]