当前位置:编程学习 > JAVA >>

ckeditor 的使用

我在javaweb 项目中 使有 ckeditor ,
做一个上传图片的功能,
写的demo ,没有问题,在IE 下 chrome 下都能 运行,
放到项目中就不行了,
在IE 下不显示ckeditor,也不能输入,chrome 下不能上传图片,
javaWeb 上是用的frameset,也有一些 jQuery 的UI.
有没有遇到的朋友,帮个忙吧 --------------------编程问答-------------------- 上传所需要的jar包添加了吗?我记得好像是5个
修改web.xml文件,配置上传功能的类
在src下创建properties文件。 --------------------编程问答-------------------- 除了楼上所讲的,你还要注意路径的问题。在jsp与html中的路径可能是有变化的。 --------------------编程问答-------------------- 我的IE 下可以啊
<script type="text/javascript">
window.onload= function(){
   CKEDITOR.replace( 'editor1',
{
filebrowserBrowseUrl : '../ckeditor/showImge.do?Type=Image',
filebrowserUploadUrl : '../ckeditor/upload.do?Type=Image'
});  
};


@RequestMapping(value = "/ckeditor/upload.do", method = RequestMethod.POST)
public void fileUpload(HttpServletRequest request,
HttpServletResponse response, @RequestParam MultipartFile upload) {
OutputStream out = null;
PrintWriter printWriter = null;
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
try {
String fileName = upload.getOriginalFilename();
byte[] bytes = upload.getBytes();
String uploadPath = getUploadpath(request) + "upload\\" + fileName;
System.out.println(uploadPath);
out = new FileOutputStream(new File(uploadPath));
out.write(bytes);
String callback = request.getParameter("CKEditorFuncNum");
System.out.println("callback:" + callback);
printWriter = response.getWriter();
String filePath = request.getContextPath() + "/upload/" + fileName;
printWriter
.println("<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction("
+ callback
+ ",'"
+ filePath
+ "',''"
+ ")</script>");
printWriter.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
if (printWriter != null) {
printWriter.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return;
}

@RequestMapping(value = "ckeditor/showImge.do")
public void showImage(HttpServletRequest request,
HttpServletResponse response) {
PrintWriter out = null;
List<String> fileList = new ArrayList<String>();
try {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
String filePath = getUploadpath(request) + "upload\\";
out = response.getWriter();
File file = new File(filePath);
String callback = request.getParameter("CKEditorFuncNum");
out.println("<script type='text/javascript' src='../ckeditor/ckeditor.js'></script>");
out.println("<script>");
out.println("function choose(obj){");
out.println("window.opener.CKEDITOR.tools.callFunction(" + callback
+ ",obj)");
out.println("window.close();");
out.println("}");
out.println("</script>");
out.println("<h2>单击图片进行选择</h2>");
if (file.exists()) {
File[] files = file.listFiles();
for (File file2 : files) {
fileList.add(file2.getName());
String fileName = file2.getName();
fileName = "../upload/" + fileName;
out.println("<img src='" + fileName + "' onclick=\""
+ "choose('" + fileName + "')\">");
out.flush();
}
}
} catch (Exception e) {
e.printStackTrace();
}
finally {
if (out != null) {
out.close();
}
}

return ;
} --------------------编程问答-------------------- 是不是你的jquery插件有冲突 --------------------编程问答-------------------- 回复二楼的哥们,我在写的一个demo 中,也是javaWeb 的demo ,可以上传图片,而且 能成功,一放到那个freamset 里就不行了。就报这样的错误,这个上传需要的包有关系吗,
--------------------编程问答-------------------- --------------------编程问答--------------------
引用 5 楼 liuc0317 的回复:
回复二楼的哥们,我在写的一个demo 中,也是javaWeb 的demo ,可以上传图片,而且 能成功,一放到那个freamset 里就不行了。就报这样的错误,这个上传需要的包有关系吗,

检查下路径那里有没弄错了,造成ckeditor没有引入进去
还有就是有没什么过滤器之类的,被拦过滤掉了 --------------------编程问答--------------------
我也不知道 检查 哪有问题了。写的webDemo 没什么错,放到项目里 就报错。
上边是 chrome js 的检查结果 。大家帮忙看看。
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,