在JavaWeb中使用wangEditor3简单案例
来源:互联网 发布:淘宝客服发的红包 编辑:程序博客网 时间:2024/05/20 02:27
介绍
wangEditor是一款基于javascript和css开发的 Web富文本编辑器,有轻量、简洁、易用、开源免费等优点。
官网:www.wangeditor.com
文档:www.kancloud.cn/wangfupeng/wangeditor3/332599
源码:github.com/wangfupeng1988/wangEditor
下载链接:github.com/wangfupeng1988/wangEditor/releases
开始
1.新建项目(使用的是struts2,配置不再赘述),将下载好的wangEditor包解压放入项目根目录
2.新建index.jsp页面将工具包中 release 文件夹下的 wangEditor.min.js或 wangEditor.js 引入到jsp页面中。index.jsp如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>wangEditor demo</title> <script src="${pageContext.request.contextPath}/js/jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script></head><body> <form action="sys.action" method="post" id="form"> <div id="editor"> <p>欢迎使用 <b>wangEditor</b> 富文本编辑器</p> </div> <input type="hidden" name="text.value" id="txt"/> <button>sss</button> </form> <script type="text/javascript" src="${pageContext.request.contextPath}/wangEditor-3.0.8/release/wangEditor.js"></script> <script type="text/javascript"> var E = window.wangEditor var editor = new E('#editor') // 或者 var editor = new E( document.getElementById('#editor') ) editor.create(); $("button").click(function(){ var html= editor.txt.html(); var text=editor.txt.text(); $("#txt").val(html); $("#form").submit(); }) </script></body></html>
demo.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>My JSP 'demo.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --><style type="text/css"> /* table 样式 */table { border-top: 1px solid #ccc; border-left: 1px solid #ccc;}table td,table th { border-bottom: 1px solid #ccc; border-right: 1px solid #ccc; padding: 3px 5px;}table th { border-bottom: 2px solid #ccc; text-align: center;}/* blockquote 样式 */blockquote { display: block; border-left: 8px solid #d0e5f2; padding: 5px 10px; margin: 10px 0; line-height: 1.4; font-size: 100%; background-color: #f1f1f1;}/* code 样式 */code { display: inline-block; *display: inline; *zoom: 1; background-color: #f1f1f1; border-radius: 3px; padding: 3px 5px; margin: 0 3px; font-family: "Courier New", Courier, monospace;}pre code { display: block;}/* ul ol 样式 */ul, ol { margin: 10px 0 10px 20px;} </style> </head> <body> <div> ${text.value} </div> </body></html>
在action中将编辑器中的值传入demo.jsp中
package base;import vo.Text;public class TextAction { private Text text; public String sys(){ System.out.println(text.getValue()); return "success"; } public Text getText() { return text; } public void setText(Text text) { this.text = text; }}
效果
index.jsp
demo.jsp
结束
更多功能请阅读官方文档,共勉!
阅读全文
1 0
- 在JavaWeb中使用wangEditor3简单案例
- JavaWeb使用Struts2的简单案例
- JavaWeb使用SpringMVC的简单案例
- 在javaweb中使用log4j
- 在JavaWeb中使用enum
- wangEditor3使用AJAX异步上传图片
- eclipse中使用Maven搭建简单javaweb
- 在javaWEB规范中使用Cookie
- VS2010中使用gtest简单案例
- javascript中cookie的简单使用案例
- [Unity3D]在游戏开发中Notification Center的简单使用与案例说明
- 深入体验JavaWeb开发内幕——使用简单标签控制页面逻辑案例
- redis在php中基本使用案例
- ssh 使用 wangeditor3 富文本编辑器上传图片方法
- 在java web项目中调用c++程序简单案例
- 在java web项目中调用c++程序简单案例
- 在文件中加入数据的简单案例
- 在java web项目中调用c++程序简单案例
- 【2017青岛网络赛】hdu 6212 Zuma 1007 区间dp
- js函数
- chrome浏览器插件,让您浏览器页面游小鱼儿
- HDU 6214 Smallest Minimum Cut
- 重装系统
- 在JavaWeb中使用wangEditor3简单案例
- idea字体细小、抗锯齿等问题
- C++中string.find()函数与string::npos 理解
- php trait学习笔记
- BZOJ 3629-聪明的燕姿 【数学杂题】
- 第三周——项目三—求集合并集
- 自定义控件---添加子控件错误
- Drupal8 minimal Mode add comment form
- Java实训课7