Ueditor富文本编辑器是在很多项目里经常用到的框架,是百度开发团队开发的一款很好用的富文本编辑器

下面就是我在一个系统里用到的,有了富文本编辑器,管理员使用起来不是很方便?

所以本博客介绍这个富文本编辑器的使用哈!觉得写得不错的请点赞哈,有建议欢迎提哈!^V^

下载链接:http://ueditor.baidu.com/website/download.html

具体的使用请看官网:http://ueditor.baidu.com/website/index.html

下载富文本编辑器后,我们打开MyEclipse或者其它编辑软件,选择file->import,选择文件系统,导入下载好的Ueditor

然后启动tomcat服务器

http://localhost:8080/项目名称t/ueditor1_4_3_2/jsp/controller.jsp?action=config

这个要根据你的项目进行修改的哈

可以输出这个,什么编辑器导入成功

引入js,charset属性设置为UTF-8的,因为我的系统默认是UTF-8的

  1. <span style="font-size:18px;"><script type="text/javascript" charset="UTF-8" src="<%=basePath %>ueditor1_4_3_2/ueditor.config.js"></script>
  2. <script type="text/javascript" charset="UTF-8" src="<%=basePath %>ueditor1_4_3_2/ueditor.all.min.js"> </script></span>

复制ueditor里面的index,html代码,这个要根据需要去复制的

  1. <span style="font-size:18px;"><script type="text/javascript">
  2. //实例化编辑器
  3. //建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
  4. var ue = UE.getEditor('editor');
  5. function getContent() {
  6. var arr = [];
  7. arr.push("使用editor.getContent()方法可以获得编辑器的内容");
  8. arr.push("内容为:");
  9. arr.push(UE.getEditor('editor').getContent());
  10. alert(arr.join("\n"));
  11. }
  12. </script></span>

因为我做的系统只要实现将编辑的文本和样式一起写入数据库,所以只要使用getContext方法就可以

在form表单里加入:

  1. <script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>

注意这些属性都不用随便修改的哦

获取文本和文本样式的参考代码,

String introduction = new String(request.getParameter("editorValue").getBytes("iso-8859-1"),"UTF-8");
  这个就是获取文本和文本样式的代码,然后下面的代码只是参考的,只要用String introduction = new String(request.getParameter("editorValue").getBytes("iso-8859-1"),"UTF-8");
  这代码就可以获取内容

  1. public class AddSpotInfoServlet extends HttpServlet {
  2. /**
  3. *
  4. */
  5. private static final long serialVersionUID = 1L;
  6. /**
  7. *
  8. */
  9. public void doGet(HttpServletRequest request, HttpServletResponse response)
  10. throws ServletException, IOException {
  11. response.setContentType("text/html;charset=UTF-8");
  12. PrintWriter out = response.getWriter();
  13. request.setCharacterEncoding("UTF-8");
  14. String introduction = new String(request.getParameter("editorValue").getBytes("iso-8859-1"),"UTF-8");
  15. String picture = Constant.ImgPath.path;
  16. String position = new String(request.getParameter("position").getBytes("iso-8859-1"),"UTF-8");
  17. String priceString = new String(request.getParameter("price").getBytes("iso-8859-1"),"UTF-8");
  18. Double price = Double.parseDouble(priceString);
  19. String sortString = new String(request.getParameter("sort").getBytes("iso-8859-1"),"UTF-8");
  20. int spot_sort = Integer.parseInt(sortString);
  21. //      String timeString = new String(request.getParameter("time").getBytes("iso-8859-1"),"UTF-8");
  22. //      Date time = Date.valueOf(timeString);
  23. String tour_project = new String(request.getParameter("tour_project").getBytes("iso-8859-1"),"UTF-8");
  24. Spot spot = new Spot();
  25. spot.setIntroduction(introduction);
  26. spot.setPicture(picture);
  27. spot.setPosition(position);
  28. spot.setPrice(price);
  29. spot.setSpot_sort(spot_sort);
  30. spot.setTour_project(tour_project);
  31. SpotDAO spotDao = new SpotDAOImpl();
  32. boolean flag = spotDao.addInfo(spot);
  33. if(flag){
  34. response.sendRedirect(Constant.WEB_URL_SPOT_SERVLET);
  35. }
  36. out.flush();
  37. out.close();
  38. }
  39. /**
  40. *
  41. */
  42. public void doPost(HttpServletRequest request, HttpServletResponse response)
  43. throws ServletException, IOException {
  44. doGet(request, response);
  45. }
  46. }

ok,可以将文本和样式一起写入数据库了,哈哈哈,^V^

WEB项目中使用UEditor(富文本编辑器)的更多相关文章

  1. vue2.0项目中使用Ueditor富文本编辑器示例

    最近在vue项目中需要使用富文本编辑器,于是将Ueditor集成进来,作为公共组件. 在线预览:https://suweiteng.github.io/vue2-management-platform ...

  2. vue2.0项目中使用Ueditor富文本编辑器应用中出现的问题

    1.如何设置config中的内容 readonly:true,//只读模式wordCount:false,//是否开启字数统计enableAutoSave: false,//自动保存功能 重点:ena ...

  3. ASP.NET MVC5 中百度ueditor富文本编辑器的使用

    随着网站信息发布内容越来越多,越来越重视美观,富文本编辑就是不可缺少的了,众多编辑器比较后我选了百度的ueditor富文本编辑器. 百度ueditor富文本编辑器分为两种一种是完全版的ueditor, ...

  4. ASP.NET MVC 中使用 UEditor 富文本编辑器

    在上篇<使用ASP.NET MVC+Entity Framework快速搭建博客系统>中,已经基本上可以实现博客分类和博客文章的CURD.但是,文章编辑界面实在是…… 好吧,咱得搞专业点. ...

  5. 在网站中使用UEditor富文本编辑器

    UEditor是由百度WEB前端研发部开发的所见即所得的开源富文本编辑器,具有轻量.可定制.用户体验优秀等特点. 官网链接 进入到下载页面,选择相应的版本下载 这里我们使用ASP.NET开发,所以选择 ...

  6. 在java项目中加入百度富文本编辑器

    富文本编辑器在项目中很常见,他可以将文本,图片等信息存入数据库,在编辑一些图文混排的信息的时候很有用,比如商城项目的商品详情页,包含很多带有样式的文字和图片. 此前一直使用的百度的富文本编辑器uedi ...

  7. 在 Vue 项目中引入 tinymce 富文本编辑器

    项目中原本使用的富文本编辑器是 wangEditor,这是一个很轻量.简洁编辑器 但是公司的业务升级,想要一个功能更全面的编辑器,我找了好久,目前常见的编辑器有这些: UEditor:百度前端的开源项 ...

  8. Vue 中使用UEditor富文本编辑器-亲测可用-vue-ueditor-wrap

    其中UEditor中也存在不少错误,再引用过程中. 但是UEditor相对还是比较好用的一个富文本编辑器. vue-ueditor-wrap说明 Vue + UEditor + v-model 双向绑 ...

  9. django项目中使用KindEditor富文本编辑器。

    先从官网下载插件,放在static文件下 前端引入 <script type="text/javascript" src="/static/back/kindedi ...

随机推荐

  1. location ^~ /images/

    } location ^~ /images/ { root /static/; } #当匹配到/images/ 开头的uri 会把网站定位到/static/下,并且不在向下继续匹配!!! 注意: ^~ ...

  2. android.animation(2) - ValueAnimator的 Interpolator 和 Evaluator

    一.插值器 插值器,也叫加速器:有关插值器的知识,我在<Animation动画详解(二)——Interpolator插值器>中专门讲过,大家可以先看看这篇文章中各个加速器的效果.这里再讲一 ...

  3. android.animation(1) - ValueAnimator的ofInt(), ofFloat(), addUpdateListener(), addListener()(转)

    一.概述 long long ago,我写过几篇有关Animation的文章,讲解了传统的alpha.scale.translate.rotate的用法及代码生成方法.其实这三篇文章讲的所有动画效果叫 ...

  4. python3+spark2.1+kafka0.8+sparkStreaming

    python代码: import time from pyspark import SparkContext from pyspark.streaming import StreamingContex ...

  5. 好工具 VHD

    通过powershell 互转 Convert-VHD –Path F:\debian.vhdx –DestinationPath F:\debian.vhd 举个栗子 附加参考 Convert-VH ...

  6. R ggplot2 翻转坐标

    p <- ggplot(mpg, aes(class, hwy)) p + geom_boxplot() p + geom_boxplot() + coord_flip()

  7. 【sql绕过】Bypass waf notepad of def

    文章是通过阅读<[独家连载]我的WafBypass之道 (SQL注入篇)>写的阅读笔记. Waf的类型 1.云waf云waf通常是CDN包含的waf,DNS在解析的时候要解析到cdn上面制 ...

  8. oracle 数据库中,应用程序里的连接探測语句的正确使用

    oracle 数据库中,应用程序里的连接探測语句的正确使用 本文为原创文章.转载请注明出处:http://blog.csdn.net/msdnchina/article/details/3851376 ...

  9. sama5d3 环境检测 gpio--yk测试

    说明: gpio的MAP关系 yk0--pioA7  yk1--pioA5   yk2--pioA9   yk3--pioA3   yk4--pioA1  yk5--pioA8    (端子从左--& ...

  10. Storm手写WordCount

    建立一个maven项目,在pom.xml中进行如下配置: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x ...