简体   繁体   中英

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:

<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?

CXFServlet is one of the transport Apache CXF uses in order to publish rest services. In other words CXF uses under the hood when publishing a Rest services JAXRS annotated (@Path) a simple Java Servlet. So the final URL where your rest services will be deployed is a concatenation between CXFServlet mapping and your rest services path.

There are other kind of transport. See http://cxf.apache.org/docs/transports.html just to understand that they are more options.

Hope this clarify you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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