UEditor (5) - Solve the error when uploading pictures: upload data not found

When using UEditor for image upload, an error is reported, saying that the upload data was not found. Because this plug-in has not encountered problems when uploading pictures before, I thought it should be a project problem. The project is an SSH framework. Baidu said that it was intercepted.

The link to this original solution: https://my.oschina.net/jiangli0502/blog/210263 , which is more detailed. I will record my own processing process here, memo.

 

1. Create your own filter and do not filter the connection of UEditor :

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;

//Custom struts2 filter
public class MyStrutsFilter extends StrutsPrepareAndExecuteFilter{
	@Override
	public void doFilter(ServletRequest req, ServletResponse res,
			FilterChain chain) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) req;
		String url = request.getRequestURI();         
		//System.out.println(url);         
		if (url.contains("/KFCenter/news/ueditor/jsp")) {//ueditor does not intercept          
			//System.out.println("Use custom filter");             
			chain.doFilter(req, res);         
		}else{             
			//System.out.println("Use default filter");             
			super.doFilter(req, res, chain);         
		}
	}
}

 2. Modify the web.xml configuration file : replace the struts with your own filter (the type of interception does not need to be changed, it is what it used to be, my project here originally filters action and jsp)

<filter>
		<filter-name>struts2</filter-name>
<!--	<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>-->
		<filter-class>com.tzj.KFCenter.action.MyStrutsFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>*.action</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>*.jsp</url-pattern>
	</filter-mapping>

 3. Pay attention to import all jar packages : The jsp version of UEditor has another jar package, so don't forget it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326201549&siteId=291194637