REST Web服务中@Path和@Requestmapping之间的区别

时间:2022-09-18 13:24:44

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?

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

1 个解决方案

#1


18  

It depends on the framework that creates the Web service

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

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

@RequestMapping是Spring框架中使用的注释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

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

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

如果您想知道哪一个更好,这个主题可能有所帮助

#1


18  

It depends on the framework that creates the Web service

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

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

@RequestMapping是Spring框架中使用的注释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

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

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

如果您想知道哪一个更好,这个主题可能有所帮助