非全部原创,部分内容来自:
http://www.icediary.net/article.asp?id=268
一、集成ckeditor
jsp文件
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
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>发表话题</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">
-->
<!-- 加载jquery -->
<script type="text/javascript" src="plugin/jquery/jquery-1.4.2.min.js"></script>
<!-- 加载ckeditor -->
<script type="text/javascript" src="<%=basePath%>/plugin/ckeditor/ckeditor.js"></script>
<!-- 加载自定义js -->
<script type="text/javascript" src="js/bbs/publishTopic.js"></script>
</head>
<body>
<table>
<tr>
<td width="30%">
</td>
<td width="70%">
</td>
</tr>
<tr>
<td>
</td>
<td>
<s:form name="pubContent" method="POST">
<s:textfield label="标题" id="topicTitle" name="topicTitle" size="80%"></s:textfield>
<s:textarea name="topicContent" id="topicContent" cols="100" rows="8" style="width:700px;height:200px;visibility:hidden;"></s:textarea>
<s:submit value="发表" onclick="return check();"></s:submit>
</s:form>
</td>
</tr>
</table>
</body>
</html>
publishTopic.js
$(document).ready(function initPage(){
showEditor();
});
//加载编辑器ckeditor
function showEditor()
{
CKEDITOR.replace( 'topicContent' );
}
//验证是否为空
function check()
{
//验证标题
var title=$("#topicTitle").val();
if(null==title||""==title){
alert("请您先输入话题标题!");
return false;
}
//验证ckeditor是否为空,topicContent是textarea的name
var content=CKEDITOR.instances.topicContent.getData();
//如果是火狐浏览器
function trim(str)
{
return str.replace(/(^\s*)|(\s*$)/g,"");
}//去掉空格
content=content.replace("<br />","");
content=content.replace("<br>","");
content=trim(content);
if(null==content||""==content){
alert("请你先输入话题内容!")
return false;
}
}
常用的一些配置,写在ckeditor的config.js中的
/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
// config.language = 'ch';
// config.uiColor = '#AADC6E';
config.language = 'zh-cn';
//config.skin = 'v2';
//config.toolbar = 'Basic';
//添加字体
config.font_names = '宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;'+ config.font_names ;
// 当提交包含有此编辑器的表单时,是否自动更新元素内的数据
config.autoUpdateElement = true;
};
分享到:
相关推荐
jsp中使用ckeditor需要的jar包,js以及本人成功使用步骤
ckEditor在jsp中的使用zckEditor在jsp中的使用
jsp环境下 ckEditor3.6.2集成ckFinder2.1
CKEditor+CKFinder+jsp的整理
内附JSP中使用CKEditor源程序实例以及CKEditor配置使用说明,以及怎么选择性的使用工具栏的条目,设置样式风格,大家可以参考,希望对大家有帮助
CKEditor在jsp中实现文件上传,java应用
CKEditor 在jsp中实现文件上传的完整例
JSP网页编辑器CKEditor含图片上传功能,本编辑器中含有一个本地图片自动上传插件,插件使用JAVA技术开发,需要配合JavaScript使用,可以将网页中含有的本地图片(src为'file:///')自动上传到服务器并修改img标签的...
4. 已知存在两个bug,(1) TableCellProperties不兼容ie浏览器,QQ浏览器及360浏览器可正常使用,此版本已去除相应插件。 5. 字数统计的中文统计不正常,仅能针对英文单词及字母正常统计,如果不使用在网页文件中可...
NULL 博文链接:https://zhouhaiyang88.iteye.com/blog/2283194
Ckeditor4菜单栏 Ckeditor4与ie兼容问题 菜单选项不能展开
CKEditor 添加Video插件(MP4)并且兼容HTML5 Video插件 1:把video文件复制到ckeditor/plugins/下面 2:ckeditor/config.js 中添加如下: a:在toolbar中['Image','Flash','Video'],配置加入“Video” 项。 b:配置 ...
UNIGUI ckeditor组件,把著名的ckeditor & ckfinder集成到ExtJS的Delphi下的UNIGUI框架。
ckeditor-rails, 集成 CKEditor javascript库和 Rails 资产管道 用于 Rails 资产管道的 CKEditorCKEditor 是一个WYSIWYG编辑器用来使用 inside 网页的库。ckeditor_rails gem 将 CKEditor 与 Rails 资产管道集成在...
该事例主要演示了如何向jsp中嵌入ckeditor编辑器。注意首先要引入ckeditor资源库。上网就可以下载。下载下来之后将其放到webRoot目录下就可以了。
集成CKEditor和CKfinder,很是纠结,发一个配置完成的,给大家分享一下。
最近项目开发需要用到CKEditor在线编辑器,但发现他本身没有自带,所以需要自己手动配置插件。但网上很多配置都有问题,自己摸索了好久终于搞定。需要注意的细节有:flvPlayer文件夹的内容直接放在ckeditor文件夹...
在这个包中,包含了原来的代码,当时这里调用了CKEditor api中的js函数,从而解决了CKEditor的项目路径问题,在CKEditor的自定义标签中不支持表达式,所以不能使用项目路径,所以需要使用js代码解决