CXF创建 Restful WebService

web.xml
   <servlet>
    	<servlet-name>cxf</servlet-name>
    	<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    </servlet>
  <servlet-mapping>
	<servlet-name>cxf</servlet-name>
	<url-pattern>/ofly/*</url-pattern>
  </servlet-mapping>

  


rest-service.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml" /> <context:property-placeholder/> <context:annotation-config/> <bean class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"/> <bean class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"/> <jaxrs:server id="services" address="/Hello"> <jaxrs:serviceBeans> <bean class="com.relonger.ofly.util.HelloWorld" /> </jaxrs:serviceBeans> <jaxrs:providers> <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/> </jaxrs:providers> </jaxrs:server> </beans>

在Spring的application.xml中添加<import resource="classpath:rest-services.xml" />

 

posted @ 2014-03-18 08:54  风语9  阅读(253)  评论(0编辑  收藏  举报