Spring MVC REST不兼容JAX-RS.有关系吗? [英] Spring MVC REST is not JAX-RS compliant. Does it matter?

查看:156
本文介绍了Spring MVC REST不兼容JAX-RS.有关系吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Spring MVC REST方面拥有丰富的经验,并交付了一些可靠的项目.我的问题是关于JAX-RS的合规性.这有关系吗,因为Spring会留在这里,而且我不希望(也没有理由)很快就要离开Spring MVC REST到Jersy或任何其他JAX-RS. 有什么应该迫使我考虑使用JAX-RS实现而不是Spring MVC REST的?

I've had good experience with Spring MVC REST with a couple of solid projects delivered. My question is about JAX-RS compliance. Does it matter because Spring is here to stay and I don't foresee (nor have a reason to) having to move away from Spring MVC REST to Jersy or any other JAX-RS impl any time soon. Anything that should force me to think about using JAX-RS implementation as opposed to Spring MVC REST?

推荐答案

恕我直言,如果您的Web应用程序仅返回JSON/XML,则没有太大区别.但是,如果Web应用程序的某些端点需要返回HTML,则Spring MVC更好.我认为是因为JAX-RS不提供任何MVC机制(AFAIK). Jersey(JAX-RS实现之一)提供了Viewable/Template来支持MVC,但它是特定于Jersey的功能,而不是JAX-RS规范的一部分.

IMHO, if your web application returns JSON/XML only, there is no big difference. However, if some end points of your web application need to return HTML, Spring MVC is better. The reason I think so is that JAX-RS does not provide any MVC mechanism (AFAIK). Jersey (one of JAX-RS implementations) provides Viewable/Template to support MVC, but it is a Jersey-specific feature and not a part of JAX-RS specification.

第18章,MVC模板
https ://jersey.java.net/documentation/latest/mvc.html

此外,此博客还可以为您提供一些见识.

Also, this blog may give you some insights.

Jersey JAX-RS MVC杀死了春季MVC明星

Jersey JAX-RS MVC Killed the Spring MVC Star
http://sleeplessinslc.blogspot.jp/2012/02/jersey-jax-rs-mvc-killed-spring-mvc.html
(The conclusion of the blog is different from its title, though.)


编辑-这是所提问题的答案:


EDIT - here's the answer to the question asked:

如上面的第二个链接所述:

As the 2nd link above says:

Jersey是一种JAX-RS实现,如果需要,可以将Jersey换成RestEasy之类的其他提供商.另一方面,Spring MVC具有REST Web服务支持,但不是JAX-RS实现,因此与Spring MVC紧密相关.

Jersey is a JAX-RS implementation, one could swap out Jersey for another provider like RestEasy if desired without much effort. Spring MVC on the other hand has REST web service support but the same is not a JAX-RS implementation and therefore one is tied to Spring MVC.

这篇关于Spring MVC REST不兼容JAX-RS.有关系吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆