Comparing Struts 1 and 2

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 classes instead of interfaces. An Struts 2 Action may implement an Action interface, along with other interfaces toenable(使..能够) optional and custom services. Struts 2 provides a base ActionSupport class to implementcommonly 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 containers generate(产生) many throw-away objects per 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 the execute method when an Action is invoked. Struts 2 Actions are not coupled(耦合) to a container. Most often(常常) the servlet contexts are represented assimple(简单的) Maps, allowing Actions to be tested in isolation(独立). Struts 2 Actions can still(仍然可以) access the original(原始的,初始) request and response, if required. However, other architectural(架构) elements reduce(减少) or eliminate(删除) the need to access the HttpServetRequest or HttpServletResponsedirectly(直接的).
Testability A major(主要的 )hurdle(障碍) to testing Struts 1 Actions is that the execute methodexposes(暴露) 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 create redundant(冗余) classes to capture input. DynaBeans can used as an alternative(供选择) 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 page via(通过) the taglibs(标签). Struts 2 also supports the ActionForm pattern(模式), as well as POJO form objects and POJO Actions. Rich object types, including business(业务) or domain(领域) 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(基本的对象结构遍历), but relatively(相对) weak collection and indexed property support. Struts 2 can use JSTL, but the framework also supports a more powerful(强大的) and flexible(灵活的) expression language(表达式语言) called "Object Graph Notation Language" (OGNL).
Binding values into views Struts 1 uses the standard(标准) JSP mechanism(机制,原理) for binding(绑定) objects into(到..里) the page context for access. Struts 2 uses a "ValueStack" technology(技术) so that the taglibs can access values without coupling(结合,耦合) your view to the object type it is rendering(表现). The ValueStack strategy allows reuse(重新使用) 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 and primitives.
Validation Struts 1 supports manual validation(手工验证) via a validate 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(分配) Request Processors(处理) (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.
利用 TensorFlow 训练自己的目标识别器。本文内容来自于我的毕业设计,基于 TensorFlow 1.15.0,其他 TensorFlow 版本运行可能存在问题。.zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值