CXF整合struts遇到的.js.css等文件被拦截

    整合CXF和struts时,出现一个js和css文件的请求被CXFservlet拦截的问题,导致页面无法显示。

<!-- CXFservlet 配置-->
<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>

<!--spring 配置 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
        	classpath*:applicationContext.xml
        </param-value>
	</context-param>
	
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	 
	

	
	<filter>
		<filter-name>encodingFilter</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>
<!-- struts配置 -->
	<filter>
		<filter-name>struts-cleanup</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
	</filter>
	
	<filter>
		<filter-name>struts</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>struts-cleanup</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<filter-mapping>
		<filter-name>struts</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	
	
	
	
	 

	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>

</web-app>

webservice配置
<jaxws:endpoint id="memcached" implementor="#memcachedWebService" address="/memcached" ></jaxws:endpoint>


以上配置webservice是可以正常调用,struts的.action请求是可以访问,但是页面显示不正常,主要原因是.js以及css文件无法显示,请求的js和css请求被当作是webservice请求拦截了

     更改:
web.xml
	<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>/ws/*</url-pattern>  
    </servlet-mapping>  

struts.xml中
添加

	<constant name="struts.action.excludePattern" value="/console/*"/>

访问webservice的url变为localhost:8080/xxx /ws/login.wsdl
url处多了一个/ws

你可能感兴趣的:(Web,webservice,servlet,struts,CXF)