ckeditor 的使用 上传所需要的jar包添加了吗?我记得好像是5个修改web.xml文件,配置上传功能的类在src下创建properties文件。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 除了楼上所讲的,你还要注意路径的问题。在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 ; } 回复二楼的哥们,我在写的一个demo 中,也是javaWeb 的demo ,可以上传图片,而且 能成功,一放到那个freamset 里就不行了。就报这样的错误,这个上传需要的包有关系吗, 检查下路径那里有没弄错了,造成ckeditor没有引入进去还有就是有没什么过滤器之类的,被拦过滤掉了 我也不知道 检查 哪有问题了。写的webDemo 没什么错,放到项目里 就报错。上边是 chrome js 的检查结果 。大家帮忙看看。 急求!!jsp页面获取登录用户信息 后台数据量很大,造成前台页面生成的时候很卡.请求一下有什么好的解决方法 关于wap实现在线视频的技术 怎么以http方式发送图片? 来者有分 用jsp如何读写文件?小弟初学 Strusts1中的bean write在struts2中用什么代替 javasrcip的问题图片滚动显示 怎么判断数据是否存在 大家看看,很简单的,就是初学者无知的表现 淘宝API怎么调用? 如何防止数据库中被注入垃圾记录
<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 ;
}
还有就是有没什么过滤器之类的,被拦过滤掉了
我也不知道 检查 哪有问题了。写的webDemo 没什么错,放到项目里 就报错。
上边是 chrome js 的检查结果 。大家帮忙看看。