溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

kindeditor使用入門-張國(guó)紅

發(fā)布時(shí)間:2020-07-08 17:16:44 來(lái)源:網(wǎng)絡(luò) 閱讀:460 作者:藍(lán)神100 欄目:編程語(yǔ)言

kindeditor是在線編輯器,比較好用,以下是提供的使用這個(gè)插件的步驟。

下載kindeditor-4.1.10.zip

解壓

kindeditor使用入門-張國(guó)紅 

asp,asp.net,php對(duì)于jsp開發(fā)沒(méi)有用,可以刪除

新建web工程,拷貝文件

WebRoot目錄下新建一個(gè)文件夾

kindeditor使用入門-張國(guó)紅 

這個(gè)文件夾是將來(lái)上傳圖片時(shí)用的,這是kindeditor默認(rèn)的,當(dāng)然也可以改,建議先按照這個(gè)文檔入了門后,再行修改。

attached一樣,在WebRoot目錄下新建目錄kindeditor目錄,把上面解壓后的文件拷貝到這個(gè)目錄下。

kindeditor使用入門-張國(guó)紅 

需要把jsp目錄下的lib目錄下的jar包拷貝到WEB-INF/lib目錄下

kindeditor使用入門-張國(guó)紅 

修改index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme() + "://"

+ request.getServerName() + ":" + request.getServerPort()

+ path + "/";

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<base href="<%=basePath%>">

<title>My JSP 'index.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" href="kindeditor/themes/default/default.css" />

<link rel="stylesheet" href="kindeditor/plugins/code/prettify.css" />

<script charset="utf-8" src="kindeditor/kindeditor.js"></script>

<script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>

<script charset="utf-8" src="kindeditor/plugins/code/prettify.js"></script>

<script>

KindEditor.ready(function(K) {

var editor1 = K.create('textarea[name="article.content1"]', {

cssPath : 'kindeditor/plugins/code/prettify.css',

uploadJson : 'kindeditor/jsp/upload_json.jsp',

fileManagerJson : 'kindeditor/jsp/file_manager_json.jsp',

allowFileManager : true,

afterCreate : function() {

var self = this;

K.ctrl(document, 13, function() {

self.sync();

document.forms['example'].submit();

});

K.ctrl(self.edit.doc, 13, function() {

self.sync();

document.forms['example'].submit();

});

}

});

//prettyPrint();

});

</script>

</head>

<body>

<div id="container">

<div id="header">

</div>

<div id="mainContent">

<form name="example" method="post" action="servlet/MyServlet">

題目:

<input type="text" name="article.title">

<br />

內(nèi)容:

<textarea name="article.content1" cols="100" rows="8"></textarea>

<br />

<input type="submit" name="button" value="提交" />

</form>

</div>

</div>

</body>

</html>

kindeditor使用入門-張國(guó)紅 

新增servlet,接收index.jsp的提交

kindeditor使用入門-張國(guó)紅 

新增index2.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme() + "://"

+ request.getServerName() + ":" + request.getServerPort()

+ path + "/";

%>

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<base href="<%=basePath%>">

 

<title>My JSP 'index.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" href="kindeditor/themes/default/default.css" />

<link rel="stylesheet" href="kindeditor/plugins/code/prettify.css" />

<script charset="utf-8" src="kindeditor/kindeditor.js"></script>

<script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>

<script charset="utf-8" src="kindeditor/plugins/code/prettify.js"></script>

<script>

KindEditor.ready(function(K) {

var editor1 = K.create('textarea[name="article.content1"]', {

cssPath : 'kindeditor/plugins/code/prettify.css',

uploadJson : 'kindeditor/jsp/upload_json.jsp',

fileManagerJson : 'kindeditor/jsp/file_manager_json.jsp',

allowFileManager : true,

afterCreate : function() {

var self = this;

K.ctrl(document, 13, function() {

self.sync();

document.forms['example'].submit();

});

K.ctrl(self.edit.doc, 13, function() {

self.sync();

document.forms['example'].submit();

});

}

});

//prettyPrint();

});

</script>

</head>

<body>

<div id="container">

<div id="header">

</div>

<div id="mainContent">

<form name="example" method="post" action="servlet/MyServlet">

題目:

<input type="text" name="article.title" value="${title }">

<br />

內(nèi)容:

<textarea name="article.content1" cols="100" rows="8">${content }</textarea>

<br />

<input type="submit" name="button" value="提交" />

</form>

</div>

</div>

</body>

</html>

 

kindeditor使用入門-張國(guó)紅 

以上是簡(jiǎn)單的入門測(cè)試。

 


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI