zoukankan      html  css  js  c++  java
  • struts1和struts2的区别

    从action类上分析:
    1.Struts1要求Action类继承一个抽象基类。Struts1的一个普遍问题是使用抽象类编程而不是接口。 
    2. Struts 2 Action类可以实现一个Action接口,也可实现其他接口,使可选和定制的服务成为可能。Struts2提供一个ActionSupport基类去实现常用的接口。Action接口不是必须的,任何有execute标识的POJO对象都可以用作Struts2的Action对象。


    从Servlet 依赖分析: 
    3. Struts1 Action 依赖于Servlet API ,因为当一个Action被调用时HttpServletRequest 和 HttpServletResponse 被传递给execute方法。 
    4. Struts 2 Action不依赖于容器,允许Action脱离容器单独被测试。如果需要,Struts2 Action仍然可以访问初始的request和response。但是,其他的元素减少或者消除了直接访问HttpServetRequest 和 HttpServletResponse的必要性。


    从action线程模式分析: 
    5. Struts1 Action是单例模式并且必须是线程安全的,因为仅有Action的一个实例来处理所有的请求。单例策略限制了Struts1 Action能作的事,并且要在开发时特别小心。Action资源必须是线程安全的或同步的。 
    6. Struts2 Action对象为每一个请求产生一个实例,因此没有线程安全问题。(实际上,servlet容器给每个请求产生许多可丢弃的对象,并且不会导致性能和垃圾回收问题)

  • 相关阅读:
    toj 1410. Euclid's Game 夜
    hdu 1404 Digital Deletions 夜
    hdu 1536 SNim 夜
    1180. Stone Game 夜
    hdu 1729 Stone Game 夜
    一个有价值的 Sharepoint WebPart 页签部件
    开始 MS Project & P3 E/C 探讨历程!
    cvccomplextype.3.2.2: Attribute 'singleton' is not allowed to appear in element 'bean
    启迪技术
    上传图片:
  • 原文地址:https://www.cnblogs.com/liuzhenping/p/7531852.html
Copyright © 2011-2022 走看看