-
错误
-
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 里面的代码修改一下
-
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 );
%>
ueditor 在线附件和在线图片路径错误BUG补丁
转载
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
在线图片压缩url软件编程
-
解决ueditor在线图片显示不出来的问题
使用ueditor,点击在线管理,服务器图片路径显示不正确,如下图所示 查看源码,如下: 发现图片src中中间多了一长串的项目跟路径,
java javascript 运维 ViewUI 持久化 -
在线图片去背景、压缩
去背景压缩大小
java 娱乐 -
免费在线图片编辑网站推荐
?「可乐改图」是一款简单易用的在线图片编辑神器,它不仅涵盖了“压缩图片”、“图片格式转换”这些基础功能,还提供了“图
人工智能 图像处理 图片编辑 压缩图片 格式转换