ueditor 在线附件和在线图片路径错误BUG补丁
- 錯(cuò)誤
- 修解決辦法
- 代碼:
錯(cuò)誤
????????? ueditor上傳附件時(shí)顯示和下載都是正常的,當(dāng)下次點(diǎn)擊在線附件時(shí)圖片圖標(biāo)顯示錯(cuò)誤,再添加到網(wǎng)頁(yè)中訪問(wèn)的時(shí)候出現(xiàn)404錯(cuò)誤,比如:
第一次添加: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)請(qǐng)求 controller.jsp?action=listimg 或者controller.jsp?action=listfile 的時(shí)候后端返回的url竟然是后臺(tái)文件的絕對(duì)路徑,導(dǎo)致前端無(wú)法訪問(wèn)資源時(shí)出現(xiàn)404錯(cuò)誤。
修解決辦法
雖然檢查了配置文件很多次了,但是還是出現(xiàn)這個(gè)問(wèn)題,也不知道是不是bug,ueditor后臺(tái)代碼挺復(fù)雜的,為了簡(jiǎn)單起見(jiàn)(怕改錯(cuò)) 就用了下面的方法偷懶一下。
代碼:
把? 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补丁的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: poj 1283(递推ordp)
- 下一篇: hdu 1723(简单dp)