zoukankan      html  css  js  c++  java
  • ueditor1.4.3jsp版在上传图片报"未找到上传文件"解决方案

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

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

     1 package com.filter;
     2 
     3 import java.io.IOException;
     4 
     5 import javax.servlet.FilterChain;
     6 import javax.servlet.ServletException;
     7 import javax.servlet.ServletRequest;
     8 import javax.servlet.ServletResponse;
     9 import javax.servlet.http.HttpServletRequest;
    10 
    11 import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;
    12 
    13 public class EditorStrutsFilter extends StrutsPrepareAndExecuteFilter{
    14     public void doFilter(ServletRequest req, ServletResponse res,
    15             FilterChain chain) throws IOException, ServletException {
    16         HttpServletRequest request = (HttpServletRequest) req;
    17         String url = request.getRequestURI();        
    18         System.out.println(url);        
    19         if (url.contains("/jsp/")) {            
    20             System.out.println("使用自定义过滤器");            
    21             chain.doFilter(req, res);        
    22         }else{            
    23             System.out.println("使用默认过滤器");            
    24             super.doFilter(req, res, chain);        
    25         }
    26     }

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

    1     <filter>
    2         <filter-name>struts2</filter-name>
    3         <filter-class>com.filter.EditorStrutsFilter</filter-class>
    4     </filter>
    5     <filter-mapping>
    6         <filter-name>struts2</filter-name>
    7         <url-pattern>/*</url-pattern>
    8     </filter-mapping>

    注意,如果有

    1   <filter>
    2         <filter-name>struts2</filter-name>
    3         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    4     </filter>

    要将其删除

    最后,希望大家转载请注明出处,尊重别人的劳动成果http://my.oschina.net/jiangli0502/blog/210263

  • 相关阅读:
    Android学习——day13
    寒假周总结三
    构建之法读书笔记03
    Android学习——day12
    每日日报2020 11/18
    每日日报2020 11/17
    每日日报2020 11/16
    每日日报2020 11/15
    每日日报2020 11/13
    每日日报2020 11/12
  • 原文地址:https://www.cnblogs.com/Wu-W-Sen/p/4108239.html
Copyright © 2011-2022 走看看