ueditor1.4.3jsp版在上传图片报"未找到上传文件"解决方案

这是因为struts2的过滤器,解决方法是自定义一个过滤器

新建一个过滤器的类,代码:

  package com.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;
 
 public class EditorStrutsFilter extends StrutsPrepareAndExecuteFilter{
     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("/jsp/")) {            
             System.out.println("使用自定义过滤器");            
             chain.doFilter(req, res);        
         }else{            
             System.out.println("使用默认过滤器");            
             super.doFilter(req, res, chain);        
         }
     }
}

之后在web.xml里面配置struts2过滤器

     <filter>
         <filter-name>struts2</filter-name>
         <filter-class>com.filter.EditorStrutsFilter</filter-class>
     </filter>
     <filter-mapping>
         <filter-name>struts2</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>

注意,如果有

   <filter>
         <filter-name>struts2</filter-name>
         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
     </filter>

要将其删除



出现上传错误是

java.lang.NoSuchMethodError: org.apache.commons.io.FileUtils.getTempDirectory()Ljava/io/File;


1:看下是否是apche的jar冲突,检查一下是否存在多个以commons-io名称开始的jar
2:FileUtils 引用jar是否版本不一致,其中没有你要的方法


你可能感兴趣的:(ueditor1.4.3jsp版在上传图片报"未找到上传文件"解决方案)