
SpringMVC的配置就不多说了,这个在网上有很多的资料,直接上我web.xml的全部配置
<?xml version="1.0" enCoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- 载入log4j配置文件 --> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:meta-inf/log4j.propertIEs</param-value> </context-param> <!--Spring默认刷新Log4j配置文件的间隔,单位为millisecond--> <context-param> <param-name>log4jRefreshInterval</param-name> <param-value>60000</param-value> </context-param> <!--Spring log4j Config loader--> <Listener> <Listener-class>org.springframework.web.util.Log4jConfigListener</Listener-class> </Listener> <!-- Spring 刷新Introspector防止内存泄露 --> <Listener> <Listener-class>org.springframework.web.util.IntrospectorCleanupListener</Listener-class> </Listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:meta-inf/applicationContext.xml </param-value> </context-param> <!-- springMVC配置 --> <servlet> <servlet-name>springMVC</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!--Spring的ApplicationContext 载入 --> <Listener> <Listener-class>org.springframework.web.context.ContextLoaderListener</Listener-class> </Listener> <!-- spring字符过滤器 --> <filter> <filter-name>characterEnCodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEnCodingFilter</filter-class> <init-param> <param-name>enCoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEnCoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapPing> <filter-name>characterEnCodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapPing>
<!--CXF配置--> <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/WebService/*</url-pattern> </servlet-mapping> <welcome-file-List> <welcome-file>index.Jsp</welcome-file> </welcome-file-List></web-app>
Spring中的配置(方法一)
<import resource="classpath:meta-inf/cxf/cxf.xml" /> <import resource="classpath:meta-inf/cxf/cxf-extension-soap.xml"/> <import resource="classpath:meta-inf/cxf/cxf-servlet.xml" /> <jaxws:endpoint ID="helloWorld" implementor="com.tiamaes.webservice.HelloWorldImpl" address="/HelloWorld" />
Spring中的配置(方法二)
<import resource="classpath:meta-inf/cxf/cxf.xml" /> <import resource="classpath:meta-inf/cxf/cxf-extension-soap.xml"/> <import resource="classpath:meta-inf/cxf/cxf-servlet.xml" /> <bean ID="helloWorldImpl" ></bean> <jaxws:endpoint ID="helloWorld" implementor="#helloWorldImpl" address="/HelloWorld" />
其中:implementor是实现类,address是地址,配置完之后可以通过 http://localhost:8080/wstest/WebService/HelloWorld?wsdl来方位到webservice
推荐用第二种方法,因为第二种你可以在类中利用spring注入属性,而第一种不可以 总结以上是内存溢出为你收集整理的构建基于CXF的WebService服务(4)--CXF与SpringMVC集成全部内容,希望文章能够帮你解决构建基于CXF的WebService服务(4)--CXF与SpringMVC集成所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)