简体   繁体   English

REST服务和Servlet

[英]REST Service and Servlet

So here I am writing my first REST Service and one thing regarding which my understanding is not clear is that there is an entry for a servlet in my web.xml file as follows: 因此,在这里,我正在编写我的第一个REST服务,关于我不清楚的一件事是,我的web.xml文件中有一个servlet条目,如下所示:

<servlet>
    <servlet-name>CXFServlet</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

So how is my service using this servlet?As in what's the use of a servlet in a REST Service?Is the service just a framework that uses the servlet's built in HTTP methods? 那么我的服务如何使用该servlet?REST服务中servlet的用法是什么?该服务仅仅是使用servlet内置HTTP方法的框架吗?

CXFServlet is one of the transport Apache CXF uses in order to publish rest services. CXFServlet是Apache CXF为了发布其余服务而使用的传输方式之一。 In other words CXF uses under the hood when publishing a Rest services JAXRS annotated (@Path) a simple Java Servlet. 换句话说,当发布带有注解(@Path)的简单Java Servlet的Rest服务JAXRS时,CXF在后台使用。 So the final URL where your rest services will be deployed is a concatenation between CXFServlet mapping and your rest services path. 因此,将在其中部署其余服务的最终URL是CXFServlet映射和您的其余服务路径之间的串联。

There are other kind of transport. 还有其他运输方式。 See http://cxf.apache.org/docs/transports.html just to understand that they are more options. 请参阅http://cxf.apache.org/docs/transports.html ,以了解它们是更多选择。

Hope this clarify you. 希望这能使您明白。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM