标签:
<filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>站点所有请求都要经过struts2过滤器,即CKFinder相关请求也会被struts2拦截,导致请求没有经过CKFinder配置的servlet。
<servlet> <servlet-name>ConnectorServlet</servlet-name> <servlet-class>com.ckfinder.connector.ConnectorServlet</servlet-class> <init-param> <param-name>XMLConfig</param-name> <param-value>/WEB-INF/ckfinder.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>false</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ConnectorServlet</servlet-name> <url-pattern>/ckfinder2.4/core/connector/java/connector.java </url-pattern> </servlet-mapping>
import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter; public class MyStrutsInterceptor extends StrutsPrepareAndExecuteFilter { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; String URI = request.getRequestURI(); String[] ckfarr = URI.split("/ckfinder2.4/core/connector/java/*/"); int arrayLen = ckfarr.length; if (arrayLen >= 2) { chain.doFilter(req, res); } else { super.doFilter(req, res, chain); } } }
标签:
原文地址:http://blog.csdn.net/justyuze/article/details/43761993