• [Cxf] spring-cxf 配置


    1.在web.xml中配置servlet
    
    <!-- spring监听的配置 -->
    <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

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

    <servlet-mapping>   <servlet-name>CXFServlet</servlet-name>   <url-pattern>/*</url-pattern> </servlet-mapping> ============================================================== <!-- CXF --> <servlet>   <servlet-name>CXFService</servlet-name>   <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> </servlet> <!-- CXF mapping--> <servlet-mapping>   <servlet-name>CXFService</servlet-name>   <url-pattern>/kjt/webservice/*</url-pattern> </servlet-mapping> =============================================================== 2 在applicationContext.xml里面配置cxf的xml <!-- webservice --> <import resource="classpath:/config/applicationContext-cxf-service.xml" /> =============================================================== 3 cxf配置文件--applicationContext-cxf-service.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:cxf="http://cxf.apache.org/core" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <!-- provider 定义 --> <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider" /> <bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" p:mapper-ref="jacksonMapper"/> <bean id="jacksonMapper" class="org.codehaus.jackson.map.ObjectMapper"> <property name="serializationConfig.dateFormat"> <bean class="java.text.SimpleDateFormat"> <constructor-arg value="yyyy-MM-dd HH:mm:ss"/> </bean> </property> <property name="serializationConfig.serializationInclusion" value="NON_NULL"></property> </bean>   <!-- 用于从json串中获取的字符串,转化成Date类型 --> <bean id="dateHandler" class="com.goldenvista.scaffold.utils.date.DateParameterHandler"> <property name="format" value="yyyy-MM-dd"></property> </bean>   
      
      <!--
    用于从json串中获取的字符串,转化成Date类型 --> <bean id="dateTimeHandler" class="com.goldenvista.scaffold.utils.date.DateParameterHandler"> <property name="format" value="yyyy-MM-dd HH:mm:ss"></property> </bean> <!-- 服务定义 ,用于模块化发布REST服务,供客户端调用--> <jaxrs:server id="ecsCarService" address="/" > <jaxrs:serviceBeans> <ref bean="kjtService" /> <ref bean="kjtMilkTraceService" /> <ref bean="userCenterService"/> <ref bean="saleService"/> </jaxrs:serviceBeans> <jaxrs:extensionMappings> <entry key="json" value="application/json"/> <entry key="xml" value="application/xml"/> </jaxrs:extensionMappings> <jaxrs:providers> <ref bean="jsonProvider"/> <ref bean="jaxbProvider"/> <ref bean="dateHandler" /> </jaxrs:providers> </jaxrs:server> </beans>
  • 相关阅读:
    编写更好的jQuery代码
    自适应网页设计(Responsive Web Design)
    精选29款非常实用的jQuery应用插件
    C# lock用法实例
    伸展树
    平衡二叉树
    搜索二叉树
    后缀表达式转为中缀表达式
    翻转链表
    双端队列
  • 原文地址:https://www.cnblogs.com/avivaye/p/3779833.html
Copyright © 2020-2023  润新知