利用struts2自带的正则匹配,应该说这算是最官方的解决方案了
在struts.properties中加正则匹配
struts.action.excludePattern=/webservice/.*
web.xml
Xml代码
1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 5 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 6 7 <context-param> 8 <param-name>contextConfigLocation</param-name> 9 <param-value>classpath:com/travelsky/rap/conf/applicationContext.xml</param-value> 10 </context-param> 11 12 <listener> 13 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 14 </listener> 15 <servlet> 16 <servlet-name>CXFServlet</servlet-name> 17 <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> 18 <load-on-startup>1</load-on-startup> 19 </servlet> 20 21 <servlet-mapping> 22 <servlet-name>CXFServlet</servlet-name> 23 <url-pattern>/webservice/*</url-pattern> 24 </servlet-mapping> 25 <!-- struts2 框架启动配置如下: --> 26 <filter> 27 <filter-name>struts2</filter-name> 28 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 29 </filter> 30 <filter-mapping> 31 <filter-name>struts2</filter-name> 32 <url-pattern>/*</url-pattern> 33 </filter-mapping> 34 35 <welcome-file-list> 36 <welcome-file>login.jsp</welcome-file> 37 </welcome-file-list> 38 </web-app>