S2SH KE编辑器 上传

在S2SH中由于我们配置的通配符为<url-pattern>/*</url-pattern>导致无法截取serlvet,当然如果你的是/*.do或者是/*.action的配置方式就不存在这个问题了,废话少说就下面就是解决方法:

serlvet过滤

过滤
package com.ly.utils.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;
/**
* 过滤struts2对此地址/editor/kindeditor4/jsp/ 的servlet拦截
*
@author Administrator
*
*/
public class KEFilter extends StrutsPrepareAndExecuteFilter {
@Override
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
//获取url地址
String URI = request.getRequestURI();
//截取ke的地址
String[] uriArray = URI
.split("/editor/kindeditor4/jsp/");
int arrayLen = uriArray.length;
if (arrayLen >= 2) {
chain.doFilter(req, res);
} else {
super.doFilter(req, res, chain);
}

}
}

web.xml

web.xml
<!--判断url地址中是否包含有KE -->
<filter>
<filter-name>struts2_ke</filter-name>
<filter-class>com.ly.utils.filter.KEFilter</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.ly.action</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2_ke</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>



 

posted @ 2012-03-09 11:01  Tony丶Lee  阅读(255)  评论(0编辑  收藏  举报