ueditor 在线附件和在线图片路径错误BUG补丁

  1. 错误

          ueditor上传附件时显示和下载都是正常的,当下次点击在线附件时图片图标显示错误,再添加到网页中访问的时候出现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查看网络可以发现,当请求 controller.jsp?action=listimg 或者controller.jsp?action=listfile 的时候后端返回的url竟然是后台文件的绝对路径,导致前端无法访问资源时出现404错误。

修解决办法

虽然检查了配置文件很多次了,但是还是出现这个问题,也不知道是不是bug,ueditor后台代码挺复杂的,为了简单起见(怕改错) 就用了下面的方法偷懒一下。

代码:

把  jsp/controller.jsp 里面的代码修改一下


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<%@ 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 );
%>


转载于:https://my.oschina.net/glenxu/blog/476849

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值