首先去ckeeditor的官网去下载http://ckeditor.com/download
吧ckeditor copy到 WebRoot下
在WebRoot下新建一个FckTest.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@page import="com.test.CkeEditorServlet"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="ckeditor/ckeditor.js">
</script>
</head>
<body>
<form action="servlet/CkeEditorServlet" method="POST">
<div style="width: 500px">
<textarea class="ckeditor" id="editor1" cols="80" rows="10"
name="editor1">
</textarea>
<script type="text/javascript">
CKEDITOR.replace('editor1', {
uiColor : '#14B8C4',
toolbar : [
//加粗 斜体, 下划线 穿过线 下标字 上标字
[ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript',
'Superscript' ],
// 数字列表 实体列表 减小缩进 增大缩进
[ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent' ],
//左对齐 居中对齐 右对齐 两端对齐
[ 'JustifyLeft', 'JustifyCenter', 'JustifyRight',
'JustifyBlock' ],
//超链接 取消超链接 锚点
[ 'Link', 'Unlink', 'Anchor' ],
//图片 flash 表格 水平线 表情 特殊字符 分页符
[ 'Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley',
'SpecialChar', 'PageBreak' ], '/',
// 样式 格式 字体 字体大小
[ 'Styles', 'Format', 'Font', 'FontSize' ],
//文本颜色 背景颜色
[ 'TextColor', 'BGColor' ],
//全屏 显示区块
[ 'Maximize', 'ShowBlocks', '-' ] ]
});
</script>
</div>
<textarea rows="20" cols="30" name="test">
</textarea>
<input type="submit" value="提交" />
</form>
</body>
</html>
---------------------------------------------------------
CkeEditorServlet 代码
package com.test;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class CkeEditorServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
process(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
process(request, response);
}
public void process(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer = response.getWriter();
String value = request.getParameter("editor1");
String testValue = request.getParameter("test");
writer.write(value);
writer.write(testValue);
writer.close();
System.out.println(value);
System.out.println(testValue);
}
}