1 Star 1 Fork 0

Eden / Notes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
UEditor 图片在线管理问题修复.md 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
Eden 提交于 2024-01-21 22:54 . update: 更换图床

UEditor 图片在线管理问题修复

问题

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

解决方法

修改 jsp/controller.jsp 的代码

  • 修改前
request.setCharacterEncoding( "utf-8" );
response.setHeader("Content-Type" , "text/html");

String rootPath = application.getRealPath( "/" );

out.write( new ActionEnter( request, rootPath ).exec() );
  • 修改后
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 );

修改 ueditor源码中 FileManager.java 的代码

  • 修改前
private String getPath ( File file ) {
    String path = file.getAbsolutePath();
    return path.replace(this.rootPath, "" );
}
  • 修改后
private String getPath ( File file ) {
    String path = PathFormat.format(file.getAbsolutePath());
    return path.replace(this.rootPath, "" );
}    
1
https://gitee.com/eden2f/notes.git
git@gitee.com:eden2f/notes.git
eden2f
notes
Notes
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891