解決ueditor編輯器圖片在線管理圖片無法顯示
阿新 • • 發佈:2017-10-11
har equal bar fix cati img nbsp set mod
使用ueditor,點擊在線管理,服務器圖片路徑顯示不正確,如下圖所示
查看源碼,如下:
發現圖片src中中間多了一長串的項目跟路徑,解決的辦法是
把 jsp/controller.jsp 裏面的代碼修改一下
[java] view plain copy
- <%@ page language="java" contentType="text/html; charset=UTF-8"
- import="com.baidu.ueditor.ActionEnter"
- pageEncoding="UTF-8"%>
- <%@ page trimDirectiveWhitespaces="true" %>
- <%
- 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 );
- %>
然後改config.json
[java] view plain copy
- /* 列出指定目錄下的圖片 */
- "imageManagerActionName": "listimage", /* 執行圖片管理的action名稱 */
- "imageManagerListPath": "/ueditor/jsp/upload/image/", /* 指定要列出圖片的目錄 */
- "imageManagerListSize": 20, /* 每次列出文件數量 */
- "imageManagerUrlPrefix": "/ueditor", /* 圖片訪問路徑前綴 */
- "imageManagerInsertAlign": "none", /* 插入的圖片浮動方式 */
- "imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 列出的文件類型 */
解決ueditor編輯器圖片在線管理圖片無法顯示