jsp中kindeditor富文本编辑器的使用



第一步:首先下载kindeditor   下载地址:http://kindeditor.net/

第二步:在网站根目录下导入kindeditor  包 如图


第三步:

开始写代码:index.jsp

<%@ page  contentType="text/html;charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的JSP标题</title>
<style>
	form {
		margin: 0;
	}
	textarea {
		display: block;
	}
</style>

<link rel="stylesheet" href="kindeditor/themes/default/default.css" />
<script charset="utf-8" src="kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>

<script>
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="text"]', {
			resizeType:1,
			allowPreviewEmoticons : false,
			allowImageUpload:false,
			items : [
				'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|', 'emoticons', 'image','table','map'],
				
				afterChange : function() {
					//K('.word_count1').html(this.count());
					K('.word_count1').html(this.count('text'));
				}	
		});
	});
</script>

</head>
<body>

<h3>默认模式</h3>
<form action="get.jsp" method="post">
	<textarea name="text" 
	style="width:700px;height:200px;visibility:hidden;">
	KindEditor</textarea>
	你输入了<span class="word_count1"></span>个字
	
	<br>
	
	<input type="submit" value="提交"/>
	
</form>


</body>
</html>

再写一个接受结果的页面:

get.jsp


<%@ page  contentType="text/html;charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>接受富文本编辑器中的文本</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
%>
<%=request.getParameter("text") %>

</body>
</html>

至此,富文本编辑器完成!



  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

275261506

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值