解决ueditor编辑器图片在线管理图片无法显示

使用ueditor,点击在线管理,服务器图片路径显示不正确,如下图所示



 查看源码,如下:



 发现图片src中中间多了一长串的项目跟路径,解决的办法是

把  jsp/controller.jsp 里面的代码修改一下

 

[java] view plain copy
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"  
  2.    
  3.     import="com.baidu.ueditor.ActionEnter"  
  4.    
  5.     pageEncoding="UTF-8"%>  
  6. <%@ page trimDirectiveWhitespaces="true" %>  
  7. <%  
  8. request.setCharacterEncoding( "utf-8" );  
  9. response.setHeader("Content-Type" , "text/html");  
  10.    
  11. String rootPath = application.getRealPath( "/" );  
  12.    
  13. String action = request.getParameter("action");  
  14. String result = new ActionEnter( request, rootPath ).exec();  
  15. if( action!=null &&   
  16.    (action.equals("listfile") || action.equals("listimage") ) ){  
  17.     rootPath = rootPath.replace("\\", "/");  
  18.     result = result.replaceAll(rootPath, "/");  
  19. }  
  20. out.write( result );  
  21. %>  

然后改config.json

 

 

[java] view plain copy
  1. /* 列出指定目录下的图片 */  
  2.    "imageManagerActionName": "listimage", /* 执行图片管理的action名称 */  
  3.    "imageManagerListPath": "/ueditor/jsp/upload/image/", /* 指定要列出图片的目录 */  
  4.    "imageManagerListSize": 20, /* 每次列出文件数量 */  
  5.    "imageManagerUrlPrefix": "/ueditor", /* 图片访问路径前缀 */  
  6.    "imageManagerInsertAlign": "none", /* 插入的图片浮动方式 */  
  7.    "imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 列出的文件类型 */  
posted @ 2017-10-11 08:56  暗渡陈仓xy  阅读(2549)  评论(0编辑  收藏  举报