当前位置: 动力学知识库 > 问答 > 编程问答 >

java - 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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: