• 测试技术
  • 博客
  • 视频
  • 开源
  • 论坛
  • 沙龙
  • 下载
  • 杂志
  • 招聘

字号: | 推荐给好友 上一篇 | 下一篇

JSP/Servlet:JSF相对于Struts的一些优点

发布: 2008-10-07 11:43 | 作者: 不详 | 来源: 测试时代采编 | 查看: 70次 | 进入软件测试时代论坛讨论

软件测试时代
关键字:
 

JSFStruts的优劣之争已经好久了。相对于Struts,本人更看好JSF,以下是转自exadel的一篇文。
 
Top Ten Reasons to Prefer JSF over Struts
I've got a client who's trying to decide whether to use Struts or JSF. As you might expect, I'm often asked, especially at NFJS symposiums, what the differences are between the two frameworks. And, of course, my client's not alone; quite a few folks are trying to decide which framework to select. 
In general, my advice is to prefer JSF for new projects. There are sometimes compelling business reasons to stay on the Struts path for existing projects and those situations usually call for some close analysis, but let's face it: JSF is much better than Struts. 

So, without further ado, here's my top-10 list of reasons to prefer JSF to Struts... 

Top Ten Reasons to Prefer JSF to Struts 

  1. Components 
  2. Render Kits 
  3. Renderers 
  4. Value Binding Expressions 
  5. Event Model 
  6. Extensibility 
  7. Managed Beans (Dependency Injection) 
  8. POJO Action Methods 
  9. JSF is the standard Java-based web app framework 
  10. There's only one Struts 

#10: There's only one Struts 
Struts is an open-source product, whereas JSF is a specification. That's a subtle distinction, which is often lost on JSF newcomers, but it's significant because we can have numerous JSF implementations. As young as JSF is, we already have two excellent JSF implementations to choose from: the Reference Implementation from Sun and MyFaces, from Apache. On the other hand, there's only one Struts. 

#9: JSF is the standard

JEE 5.0 containers must provide an implementation of JSF, which means that JSF will soon be ubiquitous. That might not matter to you, but it matters to tool vendors. With approximately 50 Java-based web app frameworks, tool vendors have been reluctant to support a particular framework, but a standard is something tool vendors can, and have, rally(ied) behind. But it's not just vendors: open source projects are rallying around JSF with such dizzying speed that they're stepping over one another to implement the same features. For example, I hadn't even heard of Facelets until we were done implementing essentially the same functionality with Shale's Tapestry-like views. (I believe that redundancy is a good thing and will serve us well in the long run) 
#8: POJO Action Methods

Struts actions are tied to the Struts API, but JSF action methods can be implemented in Plain Old Java Objects. That means you don't have to implement an additional layer of actions that mediate between your forms and your model objects. btw, notice the careful wording of this item: there are no action objects in JSF because actions are typically implemented in model objects. But also note the careful wording of that last sentence: you can certainly create separate action objects if you want with JSF. Also with Struts, you have a form bean and an action bean. The form bean contains data and the action bean contains logic. OO purists want to put them together, but you can't with Struts. In JSF, you can spread out your data and logic, or put them in one object. The choice is yours. 
#7: Managed Beans

Like Spring, JSF uses dependency injection (or inversion of control, if you will), for instantiating and initializing beans. It's true that Struts creates action beans and form beans for you, but JSF generalizes that concept and adds the ability to initialize managed beans?of any type?created by the framework. 
#6: Extensibility

文章来源于软件测试时代 http://www.testage.net/

TAG: jsf JSF Jsp JSP jsp Servlet servlet struts Struts 优点

21/212>

软件测试时代开课信息
Google
关于我们 | 合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2007 TestAge(测试时代) 北京慧灵科技有限公司 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备05002925号
技术支持和业务联系:info@testage.com.cn 电话:010-51297073