REST Web服务中@Path和@Requestmapping之间的区别 [英] Difference between @Path and @Requestmapping in REST webservice

查看:1867
本文介绍了REST Web服务中@Path和@Requestmapping之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用REST Web服务.我浏览了一些博客,在那里看到了URL到方法的映射,他们使用了不同的注释. 有些地方使用@RequestMapping,有些地方使用@Path. 两者有何不同?

解决方案

这取决于创建Web服务的框架

@RequestMapping是Spring框架中使用的注释 https://spring.io/guides/gs/rest-service/

@Path是在实现JAX-RS API的框架(例如Jersey)中使用的注释 https://jersey.java.net/documentation/latest/jaxrs-resources .html#d0e2001

如果您想知道哪个更好,请本主题可能有帮助

I am working in REST webservice. I was going through some blogs and there I saw for mapping of URL to a method, they used different annotations. Some places used @RequestMapping and some places used @Path. How does both differ?

解决方案

It depends on the framework that creates the Web service

@RequestMapping is an annotation used in Spring framework https://spring.io/guides/gs/rest-service/

@Path is an annotation used in frameworks implementing JAX-RS API, such as Jersey https://jersey.java.net/documentation/latest/jaxrs-resources.html#d0e2001

If you want to know which one is better, this topic may help

这篇关于REST Web服务中@Path和@Requestmapping之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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