1. 程式人生 > >解決ueditor編輯器圖片在線管理圖片無法顯示

解決ueditor編輯器圖片在線管理圖片無法顯示

har equal bar fix cati img nbsp set mod

使用ueditor,點擊在線管理,服務器圖片路徑顯示不正確,如下圖所示


技術分享
查看源碼,如下:


技術分享
發現圖片src中中間多了一長串的項目跟路徑,解決的辦法是

把 jsp/controller.jsp 裏面的代碼修改一下

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

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

解決ueditor編輯器圖片在線管理圖片無法顯示