| Feature | Struts 1 | Struts 2 |
|---|---|---|
| Action classes | Struts 1 requires(需要) Action classes to extend an abstract base class. Acommon(通用的) problem in Struts 1 is programming to abstract classesinstead of(代替) interfaces. | An Struts 2 Action may implement an Action interface, along with other interfaces to enable optional and custom services. Struts 2 provides a base ActionSupport class to implement commonly used interfaces. Albeit, the Action interface is not required. Any POJO object with a execute signature can be used as an Struts 2 Action object. |
| Threading Model | Struts 1 Actions are singletons(单一的) and must be thread-safe since there will only be one instance of a class to handle all requests for that Action. The singleton strategy places restrictions on what can be done with Struts 1 Actions and requires extra care to develop. Action resources must be thread-safe or synchronized. | Struts 2 Action objects are instantiated for each request, so there are no thread-safety issues. (In practice, servlet containersgenerate(产生) many throw-away objectsper(每一) request, and one more object does not impose a performance penalty or impact garbage collection.) |
| Servlet Dependency | Struts 1 Actions have dependencies(依赖) on the servlet API since the HttpServletRequest and HttpServletResponse is passed to theexecute method when an Action is invoked. | Struts 2 Actions are not coupled(耦合的) to a container. Most often the servlet contexts arerepresented(代表) as simple Maps, allowing Actions to betested(检测) in isolation(隔离). Struts 2 Actions can still access theoriginal(原有的) request and response, if required. However, other architectural elements reduce or eliminate the need to access the HttpServetRequest or HttpServletResponse directly. |
| Testability | A major hurdle(主要障碍) to testing Struts 1 Actions is that theexecute method exposes(自曝) the Servlet API.A third-party extension(三方软件), Struts TestCase, offers a set of mock object for Struts 1. | Struts 2 Actions can be tested by instantiating the Action, setting properties, and invoking methods. Dependency Injection support also makes testing simpler. |
| Harvesting Input | Struts 1 uses an ActionForm object to capture(捕获) input. Like Actions, all ActionForms must extend a base class. Since other JavaBeans cannot be used as ActionForms, developers often createredundant(多余的) classes to capture input. DynaBeans can used as analternative(替代) to creating conventional(传统的) ActionForm classes, but, here too, developers may be redescribing existing JavaBeans. | Struts 2 uses Action properties as input properties, eliminating(排除) the need for a second input object. Input properties may be rich object types which may have their own properties. The Action properties can be accessed from the web pagevia(通过) the taglibs. Struts 2 also supports(支持) the ActionForm pattern, as well as POJO form objects and POJO Actions. Rich object types, including business ordomain(定义域) objects, can be used as input/output objects. The ModelDriven feature simplifies taglb references to POJO input objects. |
| Expression Language | Struts 1 integrates(一体化) with JSTL, so it uses the JSTL EL. The EL has basic object graph traversal, butrelatively(相对) weak(较弱) collection and indexed property support. | Struts 2 can use JSTL, but the framework also supports a morepowerful(强大的) and flexible(灵活的) expression(表达式) language called "Object Graph Notation Language" (OGNL). |
| Binding values into views | Struts 1 uses the standard(标准的) JSPmechanism(机制) for binding objects into the page context for access. | Struts 2 uses a "ValueStack" technology(技术) so that the taglibs can access values withoutcoupling(耦合) your view to the object type it is rendering. The ValueStack strategy allowsreuse(重用) of views across a range of types which may have the same property name but different property types. |
| Type Conversion | Struts 1 ActionForm properties are usually all Strings. Struts 1 uses Commons-Beanutils for type conversion. Converters are per-class, and not configurable per instance. | Struts 2 uses OGNL for type conversion. The framework includes converters for basic and common object types andprimitives(基本实体). |
| Validation | Struts 1 supports manual(手动) validation(验证) via avalidate method on the ActionForm, or through an extension(扩展) to the Commons Validator. Classes can have different validation contexts for the same class, but cannot chain to validations on sub-objects. | Struts 2 supports manual validation via the validate method and the XWork Validation framework. The Xwork Validation Framework supports chaining validation into sub-properties using the validations defined for the properties class type and the validation context. |
| Control Of Action Execution | Struts 1 supports separate(单独的) RequestProcessors(处理器) (lifecycles) for each module(模块), but all the Actions in the module must share the same lifecycle. | Struts 2 supports creating different lifecycles on a per Action basis via Interceptor Stacks.Custom(自定义的) stacks can be created and used with different Actions, as needed. |
相关推荐
携程景点评论数据爬取实战:破解AJAX动态加载与分页参数逆向分析
本文详细介绍了携程景点评论数据爬取的实战经验,重点破解了AJAX动态加载与分页参数逆向分析的技术难题。通过分析`getCommentCollapseList`接口,解析动态参数如`poiId`和`pageIndex`,并实现分页逻辑,帮助开发者高效获取评论数据。文章还提供了完整的Python爬虫代码和反爬策略,适用于数据分析与内容挖掘。
diff of struts2 and struts1
在Action 实现类方面的对比:Struts 1 要求Action 类继承一个抽象基类;Struts 1 的一个具体问题是使用抽象类编程而不是接口。Struts 2 Action 类可以实现一个Action 接口,也可以实现其他接口,使可选和定制的服务成为可能。Struts 2 提供一ActionSupport 基类去实现常用的接口。即使 Action 接口不是必须实现的,只有一个包含exe...
计算机视觉-深度学习图像检测方法梳理
计算机视觉-深度学习图像检测方法梳理 由于之后要转方向啦,趁这段时间整理手中硕士研究方向的一些阅读笔记,这是一篇关于计算机视觉的基础知识梳理 先搞清一些小知识点 首先我们要弄清楚图像分类、目标定位、语义分割、实例分割的区别 a. 图像分类 :给定一张输入图像,图像分类任务旨在判断该图像所属类别; b. 目标定位 :在图像分类的基础上,我们还想知道图像中的目标具体在图像的什么位置,通常是以包围盒的(bounding box)形式; c. 语义分割 :语义分割是目标检测更进阶的任务,目标检测只需要框出每个目
Struts2_与Struts1比较and基本配置
<br />Struts2有以下优点:在软件设计上struts2没有像struts1那样跟Servlet API和struts API有着紧密的耦合,struts2应用可以不依赖于Servlet API和Struts API,Struts2的这种设计属于无侵入式设计。Struts2提供了拦截器,利用拦截器可以进行AOP编程,实现如权限拦截的功能。Struts2提供了类型转换器,我们可以把特殊的请求参数转换成需要的类型。Struts1中,如果要实现同样的功能,就必须向Struts1的底层实现BeanUtil注
Quest 3开发第一步:搞定Meta账号登录和Oculus软件连不上设备的那些坑(2024实测)
本文详细介绍了Quest 3开发初期的关键步骤,包括Meta账号注册、Oculus软件安装与设备连接等常见问题的解决方案。针对国内开发者遇到的邮箱限制、验证码接收等难题,提供了实用的应对策略,并分享了开发环境配置和常见问题排查技巧,帮助开发者快速搭建Quest 3开发环境。
赛灵思Xilinx 7系列FPGA硬件设计知识总结
本文讲述了赛灵思7系列FPGA硬件设计的关键点,为使用该系列FPGA提供硬件设计参考。
sturts1 and struts2
Struts作为MVC 2的Web框架,自推出以来不断受到开发者的追捧,得到广泛的应用。作为最成功的Web框架,Struts自然拥有众多的优点:MVC 2模型的使用、功能齐全的标签库(Tag Library)、开放源代码。 但是,正所谓“没有最好,只有更好”,Struts1.x自身也有不少的缺点:需要编写的代码过多,容易引起“类爆炸”、单元测试困难。这些缺点随着Web的发展越来越明显。这
UE5与Cesium for Unreal结合:打造高效离线地图解决方案
本文详细介绍了如何利用UE5与Cesium for Unreal结合打造高效离线地图解决方案,特别适用于数字孪生、军事仿真等网络不稳定场景。通过优化配置、数据处理和性能调优,实现TB级地形数据的流畅渲染,并结合实战案例展示了在油田巡检等复杂环境中的应用效果。
Comparing Struts1 and Struts2
Feature Struts 1 Struts 2 Action classes Struts 1 requires Action classes to extend an abstract base class. A common problem in Struts 1 is programming to abstract classes instead of interface
5分钟搞定Unity+Visual Studio开发环境配置(含C#游戏开发工作负载)
本文提供了一份详细的Unity与Visual Studio开发环境配置指南,帮助开发者在5分钟内完成C#游戏开发工作负载的设置。从Unity Hub安装到Visual Studio关键组件选择,再到常见问题排查,全面覆盖环境搭建的各个环节,显著提升游戏开发效率。
华为OD机试真题 新系统【小花获胜的奶茶】
华为OD机试真题 新系统【小花获胜的奶茶】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题 【小花获胜的奶茶】多语言题解。
difference between struts1 and struts2
struts2 struts1 difference
【Simulink教程案例19】基于simulink的扩频通信系统建模与仿真
扩频是一种应用于数字调制信号的调制技术,可以提高传输信号的带宽。扩频通信具有抗干扰能力强,扩频增益越大,抗干扰能力越强。而且扩频通信具有很强的保密性,扩频后信号近似白噪声,功率谱密度也很低。扩频通信可用于多址通信。扩频调制有如下三个特点:① 扩频后信号的带宽远大于信号所需的带宽② 使用扩频码进行扩频调制,扩频码与信号中的数据相互独立③ 在接收端,通过将接收信号与扩频码的同步副本进行相关,实现解扩。
Comparing Struts 1 and 2
Feature Struts 1 Struts 2 Action classes Struts 1 requires Action classes to extend an abstract base class. A common problem in Struts 1 is programming to abstract classes instead of i
蓝牙模块HM-10手册
蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。
pscad IEEE标准系统搭建说明
pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。
difference between struts1.x and Struts2.x
<br />http://www.geekinterview.com/question_details/64360<br /> eature Struts 1 Struts 2 Action classes Struts1 extends the abstract base class by its action class. The problem with struts1 is that it uses the abstract classes rather than interfaces. W
WINCC7.3破解文件
WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!
struts1 and struts2区别()
1) 在Action实现类方面的对比:Struts 1要求Action类继承一个抽象基类;Struts 1的一个具体问题是使用抽象类编程而不是接口。Struts 2 Action类可以实现一个Action接口,也可以实现其他接口,使可选和定制的服务成为可能。Struts 2提供一个ActionSupport基类去实现常用的接口。即使Action接口不是必须实现的,只有一个包含execute方法的P
汉书HE8,好用的汇编代码编写工具
汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大
转:Comparing Struts 1 and 2
Feature Struts 1 Struts 2 Action classes Struts 1 requires Action classes to extend an abstract base class. A common problem in Struts 1 is programming to abstract classes instead of ...
比较Struts1.x和struts2.0 and struts2.1
<br />Struts实现了MVC模式,结构清晰,使开发者能过关注业务逻辑的实现.在应用Struts框架做项目开发的过程中我们更能体会到这种模式的优越性。下面就简单的谈谈不同Struts版本之间的差异:<br />首先,从web.xml配置文件中所配置的前端控制器谈起.<br /> Struts1.x的前端控制器是一个Servlet;<br /> Struts2的前端控制器是一个filter,Struts2.0中的名字是Filterdispatcher;Struts2.1中的名字是StrutsPrep
674



被折叠的 条评论
为什么被折叠?



