ueditor 在线附件和在线图片路径错误BUG补丁
- 錯誤
- 修解決辦法
- 代碼:
錯誤
????????? ueditor上傳附件時顯示和下載都是正常的,當(dāng)下次點擊在線附件時圖片圖標(biāo)顯示錯誤,再添加到網(wǎng)頁中訪問的時候出現(xiàn)404錯誤,比如:
第一次添加:http://192.168.1.4:8080/uedit2/ueditor/jsp/upload/file/20140622/1403423931425017681.png
第二次就變成了:http://192.168.1.4:8080/uedit2/C:/Program Files/Apache Software Foundation/Tomcat 7.0/wtpwebapps/uedit2/ueditor/jsp/upload/file/20140622/1403423931425017681.png
??????? 用firebug查看網(wǎng)絡(luò)可以發(fā)現(xiàn),當(dāng)請求 controller.jsp?action=listimg 或者controller.jsp?action=listfile 的時候后端返回的url竟然是后臺文件的絕對路徑,導(dǎo)致前端無法訪問資源時出現(xiàn)404錯誤。
修解決辦法
雖然檢查了配置文件很多次了,但是還是出現(xiàn)這個問題,也不知道是不是bug,ueditor后臺代碼挺復(fù)雜的,為了簡單起見(怕改錯) 就用了下面的方法偷懶一下。
代碼:
把? jsp/controller.jsp 里面的代碼修改一下
| 123456789101112131415161718192021 | <%@ 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 );%> |
總結(jié)
以上是生活随笔為你收集整理的ueditor 在线附件和在线图片路径错误BUG补丁的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: poj 1283(递推ordp)
- 下一篇: hdu 1723(简单dp)