• Ueditor JSP HelloWorld及图片上传


    Ueditor首页:http://ueditor.baidu.com/website/

    HelloWorld:

    引入:

    <script type="text/javascript" charset="utf-8" src="../ueditor/editor_all.js"></script>
    <script type="text/javascript" charset="utf-8" src="../ueditor/editor_config.js"></script>

    配置:

    //配置Ueditor的地址
    var URL = window.UEDITOR_HOME_URL||"/company/ueditor/";  

    JS:

    //name="content"  后台获取数据的名字即 request.getParameter("content");
    <textarea id="myEditor" name="content" cols="80" rows="20" class="textarea">可以写入初始化内容</textarea> <script type="text/javascript"> UE.getEditor('myEditor',{ initialFrameWidth:1000 ,initialFrameHeight:350 ,initialContent:"" ,charset:"gb2312" //工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的从新定义 ,toolbars:[["fullscreen","source","undo","redo","insertunorderedlist","insertorderedlist","unlink","link","cleardoc","selectall","print","searchreplace","preview","help","pagebreak","insertimage","music","snapscreen","emotion","insertvideo","attachment","insertframe","date","time","horizontal","blockquote","highlightcode","template","background","bold","italic","underline","strikethrough","forecolor","backcolor","superscript","subscript","justifyleft","justifycenter","justifyright","justifyjustify","indent","removeformat","formatmatch","pasteplain","customstyle","imagecenter","imageright","imageleft","imagenone","fontsize","fontfamily","lineheight","rowspacingtop","rowspacingbottom","paragraph","inserttable","deletetable","mergeright","mergedown","splittorows","splittocols","splittocells","mergecells","insertcol","insertrow","deletecol","deleterow","insertparagraphbeforetable"],[],[]] }); </script>

    据此helloworld就配好了。

    图片上传:

    配置上传地址(采用默认地址也可上传,但是在ueditor/jsp/ 文件夹下):

    //和生成图片链接有关
    ,imagePath: "/company/uploadImages/"

    配置JSP地址:

    //和保存文件有关,由于处理的JSP文件和实际图片上传的文件夹不是同级别关系,因此配置路径比较麻烦,不过多测试几次就可以
    request.setCharacterEncoding("gbk");
    response.setCharacterEncoding("gbk");
    Uploader up = new Uploader(request);
    up.setSavePath(../../uploadImages/);
    ...
    //这里返回的地址使用up.getUrl(); 通常也是有问题的,需要处理后才能生成正确的链接地址。
    response.getWriter().print("{'original':'"+up.getOriginalName()+"','url':'"+up.getUrl()+"','title':'"+up.getTitle()+"','state':'"+up.getState()+"'}");

  • 相关阅读:
    JavaWeb之Servlet的生命周期
    Java之HashMap和HashTable的区别
    Java之使用中间缓存变量机制
    哪项技术可以用在WEB开发中实现会话跟踪实现?
    Spring的简单定时任务的实现
    Java解决No enclosing instance of type PrintListFromTailToHead is accessible问题
    StringBuffer和StringBuilder的区别
    论文阅读笔记:《Generating Question-Answer Hierarchies》
    python学习笔记(十)——正则表达式和re模块
    Python学习笔记(九)——字符串
  • 原文地址:https://www.cnblogs.com/hzm112567/p/2938040.html
Copyright © 2020-2023  润新知