`

struts2学习笔记(2)--Struts 2.0 特性

阅读更多
struts2的一些新特性:

  • Improved design: In contrast with Struts 1, all of the Struts 2 classes are based on interfaces. Core interfaces are HTTP independent. These APIs are not dependent on Servlet APIs.
  • Simplified Actions: Struts 2 Action classes are framework independent and are simplified plain old Java objects (POJO). Any Java class with an execute() method can be used as an Action class.
  • POJO forms: Struts 2 does not support the ActionForms feature. The properties that are defined in the ActionForms can be put directly on the Action classes. You do not need to use all String properties.
  • Intelligent defaults: Most of the configuration elements in the Struts 2 configuration file will have default values, so there is no need to set values unless a different value is required. This helps reduce the configuration you need to do in the XML file. Struts 2's support for annotations helps make this even easier to achieve.
  • Enhanced results: In Struts 2, the >forward< tag is replaced by the <result> tags. Unlike ActionForwards, Struts 2 results help in preparing the response and provide flexibility to create multiple types of output.
  • Enhanced tags: Struts 2 tags don't just send output data, but also provide stylesheet-driven markup so that you can create consistent pages with less code. Struts 2 tags can now work with FreeMarker, Velocity, and similar template engines.
  • Introduction of interceptors: Struts 2 provides exhaustive support for interceptors. Interceptors can be executed before and after an Action class is executed. Interceptors are configured to apply common functionality, such as workflow or validation, to a request. All the requests pass through a set of interceptors before they are sent to an Action class. After the Action class is executed, the request passes through the interceptors again in the reverse order.
  • Ajax support: To create dynamic Web applications that use Ajax, Struts 2 provides an Ajax theme, which gives interactive applications a significant boost. Struts 2 tags for Ajax are based on Dojo widgets. Plug-ins are available for other frameworks as well.
  • QuickStart: Deployed configuration files are reloadable; hence, many changes can be made on the fly without the need to restart the Web container.
  • Stateful checkboxes: The Struts 2 framework automatically tracks checkboxes; if a checkbox is missing, the default value -- false -- is assumed. Hence, unlike in Struts 1, checkboxes do not require special handling for false values.
  • Easy testing: Struts 2 Actions are HTTP independent and thus framework neutral. They can be tested easily without using mock objects.
  • Use of annotations: Applications built using Struts 2 can use Java 5 annotations as an alternative to XML and Java properties configuration. Annotations minimize the need for XML. Annotations are available for Actions, interceptors, validation and type conversion.
  • Easy plug-in: Struts 2 extensions can be installed by dropping the plug-in JAR file into the \WEB-INF\lib directory. No manual configuration is required.
  • Easy integration with Spring: Struts 2 Actions are Spring-aware. Just adding Spring beans to an application will add Spring support.
  • Easily customized controllers: Struts 1 allows the request processor to be customized per module; in Struts 2, you can customize the request handling per action, if required.
2
1
分享到:
评论
2 楼 weidewei 2008-06-02  
Struts 2本来就是这么简单的.跟wenwork没有什么大区别.常用的基本都在这里面了.
1 楼 Ethip 2008-06-01  
如此简洁?

相关推荐

    struts2.0学习笔记1

    struts2.0学习笔记1 自己动手做的还算可以的 ]struts2.0学习笔记1 自己动手做的还算可以的struts2.0学习笔记1 自己动手做的还算可以的struts2.0学习笔记1 自己动手做的还算可以的

    struts2.0学习笔记

    本篇笔记将详细介绍如何在MyEclipse环境中配置Struts2.0,并逐步演示从创建运行环境到实现简单的验证和自定义类型转换的过程。 首先,我们需要准备运行环境。MyEclipse 6.0 和 Tomcat 5.5 是开发Struts2.0应用的...

    struts2.0学习笔记,代码整理

    本学习笔记主要涵盖了Struts2.0的基础概念、核心组件、配置方法以及实际代码示例,旨在帮助开发者更好地理解和运用这个框架。 一、Struts2.0基础 Struts2.0是Apache软件基金会的开源项目,它是Struts1.x的升级版本...

    struts2学习笔记.doc

    ### Struts2学习笔记知识点概览 #### 一、环境搭建 **1.1 Struts2简介** - **Struts2概述**:Struts2是一个开源的MVC框架,它结合了Struts 1.x、WebWork和其他一些框架的优点。Struts2的主要目标是简化Web应用程序...

    struts2学习笔记(1)

    ### Struts2学习笔记知识点详解 #### 一、Struts2框架的基本引入步骤 ##### 1. 导入Struts2相关Jar包 在引入Struts2框架时,首先需要将Struts2的相关Jar包导入到项目的类路径中。这些Jar包通常包括核心库以及其他...

    Struts2.0学习笔记.doc

    Struts2.0是一个流行的Java Web开发框架,它极大地简化了MVC(模型-视图-控制器)架构的实现。在Struts2中,类型转换是自动进行的,旨在帮助开发者处理请求参数与Action类属性之间的类型匹配问题。文档中的内容主要...

    Struts2.0培训笔记

    本培训笔记将深入探讨Struts2.0的核心概念、特性以及如何在实际项目中有效应用。 一、Struts2.0框架基础 Struts2.0是Apache软件基金会的项目,它是Struts1.x的升级版,提供了更强大的功能和更好的性能。该框架通过...

    struts2.0笔记(1)

    Struts2.0是在Struts1.x的基础上发展起来的,它引入了许多新特性,提高了开发效率并增强了可扩展性。首先,Struts2.0采用拦截器(Interceptor)机制来处理请求,使得业务逻辑与控制逻辑分离,更易于维护。拦截器堆栈...

    struts 2 学习笔记

    以上内容仅是Struts2学习笔记中的核心部分,实际学习时还需要深入理解拦截器、结果类型配置、插件机制、异常处理等更多高级特性。Struts2提供了强大的功能和灵活性,是Java Web开发中不可或缺的一部分。

    struts2.0相关学习资料

    通过阅读Struts2.0中文手册和学习笔记,以及动手实践教程中的示例,可以全面掌握Struts2.0的用法和精髓。在实际项目中,熟练运用Struts2.0能提高开发效率,降低维护成本。同时,了解并熟悉相关的社区资源和最佳实践...

    struts2学习笔记!

    ### Struts2学习笔记 #### 一、Struts2配置文件详解 在深入理解Struts2框架之前,我们首先需要了解其核心配置文件——`struts.xml`。 **1. struts.xml配置** ```xml &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!...

    struts2.0实例源码

    struts2.0实例源码(struts2是我写的struts2Deom是我下的资源项目一起给大家) 包括strust2.0的所有知识面,每个点我都写了详细注释 网上是很难找到这样的资料的,这是我个人学习笔记拿出来希望跟大家一起学习...

    Struts2学习笔记与心得

    ### Struts2与Struts1对比及特性解析 #### 一、Struts2与Struts1的区别 在探讨Struts2的学习心得之前,我们先来分析一下Struts2与Struts1之间的区别。 ##### 1.1 架构设计 - **Struts1**:采用MVC(Model-View-...

Global site tag (gtag.js) - Google Analytics