5. UEditor 完善 图片在线管理 问题

152 阅读1分钟

问题 : 图片能够正常上传,正常显示,但是在线管理那里的图片显示不了。

  1. 如图:

  2. 解决方法:

    1. 修改 jsp/controller.jsp 的代码

      1. 修改前:

            request.setCharacterEncoding( "utf-8" );
        	response.setHeader("Content-Type" , "text/html");
        	
        	String rootPath = application.getRealPath( "/" );
        	
        	out.write( new ActionEnter( request, rootPath ).exec() );
        
      2. 修改为: request.setCharacterEncoding( "utf-8" ); response.setHeader("Content-Type" , "text/html");

        	String rootPath = application.getRealPath( "/" );
        	
        	String action = request.getParameter("action");  
        	String result = new ActionEnter( request, rootPath ).exec();  
        	if( action!=null &&   
        	   (action.equals("listfile") || action.equals("listimage") ) ){  
        	    rootPath = rootPath.replace("\\", "/");  
        	    result = result.replaceAll(rootPath, "/");  
        	}   
        	out.write( result );
        
    2. 修改 ueditor源码中 FileManager.java 的代码

      1. 修改前:

        private String getPath ( File file ) {
            String path = file.getAbsolutePath();
            return path.replace(this.rootPath, "" );
        }
        
      2. 修改为 private String getPath ( File file ) { String path = PathFormat.format(file.getAbsolutePath()); return path.replace(this.rootPath, "" ); }