上传所需要的jar包添加了吗?我记得好像是5个
修改web.xml文件,配置上传功能的类
在src下创建properties文件。

解决方案 »

  1.   

    除了楼上所讲的,你还要注意路径的问题。在jsp与html中的路径可能是有变化的。
      

  2.   

    我的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 ;
    }
      

  3.   

    回复二楼的哥们,我在写的一个demo 中,也是javaWeb 的demo ,可以上传图片,而且 能成功,一放到那个freamset 里就不行了。就报这样的错误,这个上传需要的包有关系吗,
      

  4.   

    检查下路径那里有没弄错了,造成ckeditor没有引入进去
    还有就是有没什么过滤器之类的,被拦过滤掉了
      

  5.   


    我也不知道 检查 哪有问题了。写的webDemo 没什么错,放到项目里 就报错。
    上边是 chrome js 的检查结果 。大家帮忙看看。