解決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"], /* 列出的文件類型 */  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM