三.百度编辑器UEditor在status2中拦截器的配置

status2中使用百度UEditor 编辑器上传图片拦截器配置:

拦截器类代码:

package xxx.util;

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;
/**
 * 此过滤器处理百度默认的图片上传
 * @author sunlight
 *
 */
public class StrutsFilter extends StrutsPrepareAndExecuteFilter {
	//此处继承status2的拦截器StrutsPrepareAndExecuteFilter
	@Override
	public void doFilter(ServletRequest req, ServletResponse res,FilterChain chain) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) req;  
        //不过滤的url  
        String url = request.getRequestURI(); 
        
        if (url.contains("/ueditor/jsp/")) { 
	    //System.out.println("aaa使用自定义的过滤器");  
            chain.doFilter(req, res);
        }else{  
	    //System.out.println("使用默认的过滤器");  
            super.doFilter(req, res, chain);  
        }  
    }
	
}

web.xml 配置:

<!-- 配置Struts2过滤器 -->
<filter>
	<filter-name>assn</filter-name>
	<filter-class>xxx.util.StrutsFilter</filter-class>
</filter>

<filter-mapping>
	<filter-name>assn</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>

还有其他处理方法,希望大家和我一起交流...谢谢!

你可能感兴趣的:(web.xml,struts2,ueditor,文本编辑,编辑器)