开发者

Spring compared to JSF 2 [closed]

开发者 https://www.devze.com 2022-12-18 06:05 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_运维知识库 Closed 9 years ago.

I haven't used Spring, but it sounds like it is fairly popular. I heard that it provides alternate ways of doing things, such as being able to consume RESTful web services. Does anyone know if provides similar features as those introduced by JSF 2, or would I be comparing apples to oranges?

Edit:

Thanks for the information. Comparing Spring MVC to JSF 2, would there be advantages of using Spring MVC instead of JSF 2 functionality?

Thanks.


Apples to Oranges.

Spring is an application framework that integrates dependency injection, aspect oriented programing and several other things in one stack. Its rough apples to apples comparison would be J2EE.

JSF is a view layer technology, built on the Model View Controller paradigm. Its rough oranges to oranges comparison would be Spring MVC. Both can use different View technologies (ie. Facelets, JSP, Velocity, etc.) and both integrate extremely well into their respective stacks.

-- In response to the new question --

I've used JSF2 a fair amount (as much as anyone can given its young age) and I find it to be a very good framework. It fixes a lot of the shortcomings of JSF 1.2 and I felt that JSF 1.2 was a good match for me too.

I've not used Spring MVC much but I have looked at some code that another developer has done.

My (very) limited experience is that Spring MVC feels slightly more like an "action" framework while JSF feels more like a "component" framework. I, personnaly, think that the component-esque frameworks are a more natural extension of OOD, which appeals to me and the way I write software.


Spring MVC is a web framework inside the Spring framework. It does provide features as those in JSF 2.0:

  • ajax-support
  • validation
  • dependency-injection
  • etc.

Yet, you can use Spring (not Spring MVC) together with JSF 2.0, with spring providing the dependency-injection, aop, transaction management mechanisms, and JSF providing the web layer.


JSF is just the view layer of the MVC and wil need to be used with other technologies like Spring/Hibernate or EJB for a full MVC.

Spring (not the Spring MVC) is the controller layer of the MVC and as I say can be used with something like JSF (Struts, JSP/Servlets etc) and something like Hibernate.

I have been using the Spring MVC for about 6 months now, whilst it's probably not the latyest version of SpringMVC I've found it a little annoying that we have so much XML to deal with. All the managed beans and DAO has XML config to it. Also everything seems to have to go thorugh a method called onSubmit().

JSF with something like EJB is far simplier in my opinion... Everything can be done using Annotations so simply use @ManagedBean=theBean in your backing bean and in your JSF put {thebean.param} and you have access to the backing bean's data. Also you can use the Session beans of your EJB as the backing beans for JSF then have direct acces to the DAO (Model layer) Entity bean. Again simply by using the @Entity annotation and the EntityManager class

Also I like the way you are free to set your own action methods so you can have a method in your bean called TheBean.addDetails() and call it in the JSF with theBean.addDetails() rather than everything going through one method as with the Spring MVC.

JSF as I say is just the view layer of MVC, personally I like using it with EJB as this gives you the full MVC all from within Suns J2EE.jar so there are no issues with making sure you have the correct versions and no configuration required.

JSF 2.0 is far suprior to JSF1.2 which always felt like half a job as with EJB3.1 which is nothing like EJB2.x and is far better than EJB3.0 even. For me JSF2.0 with EJB3.1 is so simple and easy to develop with and everything is very transparent.


I was working with JSF 1.2 + JSF managedbeans for 2 years and now I have started migrating to JSF2.0. After getting to know about Spring and Spring MVC, I feel that a JSF(1.2 or 2.0) + Spring(service and not MVC) +Hibernate will be a very good architecture.


One of worst part of Spring billions configurations, even in Spring3 you must have config files... For example you have SOAP web service and want to integrate Spring as backend.. and you can find what you can not inject Spring beans in regular web service.. and you must change also your services to Spring SOAP..... Spring3 used annotations, but it is annoyed you every time to guess which annotation to use for opening or closing some services.... Instead you can have just EJB3.1 which is power, simple and as java developer you can just enjoy it. I noticed what a lot of Spring fans do not know EJB3 anymore, whats why they like Spring:)))


JSF2 can be used as backend and as frontend, and also it have better dependency injection, navigation and validation than Spring MVC.

Spring itself can be used as enterprise framework instead EJB3.1/EJB3.1 better/, but as frontend JSF2 with primefaces have not alternatives.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号