FCK编辑器在JSP中使用基本说明(来自http://blog.360quan.com/u/1281c9/show/506089)
2008-02-29 11:25
246 查看
步骤1:将fckeditor文件夹拷贝到/WebRoot目录下
步骤2:将lib文件夹下的两个jar文件拷贝到/WebRoot/WEB-INF/lib目录下
步骤3:将FCKeditor.tld文件拷贝到/WebRoot/WEB-INF目录下
步骤4:将Web.xml文件中的内容拷贝到工程的web.xml文件中,注意里面两个Servlet配置的路径修改
在JSP页面配置FCKeditor编辑器
/**
* 方法一:
*/
在JSP页面头部配置
<%@ page language="java" import="com.fredck.FCKeditor.*"%>
在<body>标签你想放置FCKeditor编辑器的地方配置
<%
// 获得上下文路径
String path = request.getContextPath();
FCKeditor oFCKeditor;
// 定义一个属性来使Action通过request来获得FCKeditor编辑器中的值
oFCKeditor = new FCKeditor(request, "content");
oFCKeditor.setBasePath(path + "/fckeditor/");
// 设置FCKeditor编辑器打开时的默认值
oFCKeditor.setValue("input 1111");
out.println(oFCKeditor.create());
%>
/**
* 方法二:
*/
在JSP页面头部配置
<%@ taglib uri="/MyFCKeditor" prefix="FCK"%>
注意这个uri,也可以写为"/WEB-INF/FCKeditor.tld",这里的写法其实是已经将tld文件配置在工程的web.xml文件中了
在<body>标签你想放置FCKeditor编辑器的地方配置
<FCK:editor id="content" <!-- 定义FCKeditor的标志,以便Action获得其值-->
basePath="fckeditor/" <!-- 注意这里为FCKeditor的基本路径,无需配置上下文路径-->
imageBrowserURL="/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
linkBrowserURL="/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
flashBrowserURL="/fckeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector">
this is default content :)
</FCK:editor>
Q:Action中如何获得FCKeditor中的内容?
A:很简单,上面两种方法对FCKeditor的标记都为content,在Action中用request.getParameter("content")即可。注意的是,这里获得的字符串是包括html标签的(即FCKeditor的值的HTML源代码)。
Q:FCKeditor中的按钮太多,只要其中一些该如何修改?
A:在fckconfig.js文件中修改,代码如下:
FCKConfig.ToolbarSets["Default"] = [
['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor','Image','Flash'],
['TextColor','BGColor','Table','Rule'],
['Style','FontFormat','FontName','FontSize']
] ;
将不用的删除即可。
Q:FCKedior中如何使用JavaScript来获得和设置其中的内容
A:<script type="text/javascript">
// 获得编辑器中的HTML内容
function getHTMLValue()
{
var oEditor = FCKeditorAPI.GetInstance("content");
var value = oEditor.GetXHTML(true);
alert(value);
}
// 获得编辑器中的文本内容
function getTextValue()
{
var oEditor = FCKeditorAPI.GetInstance("content");
var value = oEditor.EditorDocument.body.innerText;
alert(value);
}
// 设置编辑器中的内容
function initFCK()
{
var oEditor = FCKeditorAPI.GetInstance("content");
oEditor.SetHTML("<p><font color='red'>aaa</font></p>");
}
</script>
步骤2:将lib文件夹下的两个jar文件拷贝到/WebRoot/WEB-INF/lib目录下
步骤3:将FCKeditor.tld文件拷贝到/WebRoot/WEB-INF目录下
步骤4:将Web.xml文件中的内容拷贝到工程的web.xml文件中,注意里面两个Servlet配置的路径修改
在JSP页面配置FCKeditor编辑器
/**
* 方法一:
*/
在JSP页面头部配置
<%@ page language="java" import="com.fredck.FCKeditor.*"%>
在<body>标签你想放置FCKeditor编辑器的地方配置
<%
// 获得上下文路径
String path = request.getContextPath();
FCKeditor oFCKeditor;
// 定义一个属性来使Action通过request来获得FCKeditor编辑器中的值
oFCKeditor = new FCKeditor(request, "content");
oFCKeditor.setBasePath(path + "/fckeditor/");
// 设置FCKeditor编辑器打开时的默认值
oFCKeditor.setValue("input 1111");
out.println(oFCKeditor.create());
%>
/**
* 方法二:
*/
在JSP页面头部配置
<%@ taglib uri="/MyFCKeditor" prefix="FCK"%>
注意这个uri,也可以写为"/WEB-INF/FCKeditor.tld",这里的写法其实是已经将tld文件配置在工程的web.xml文件中了
在<body>标签你想放置FCKeditor编辑器的地方配置
<FCK:editor id="content" <!-- 定义FCKeditor的标志,以便Action获得其值-->
basePath="fckeditor/" <!-- 注意这里为FCKeditor的基本路径,无需配置上下文路径-->
imageBrowserURL="/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
linkBrowserURL="/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
flashBrowserURL="/fckeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector">
this is default content :)
</FCK:editor>
Q:Action中如何获得FCKeditor中的内容?
A:很简单,上面两种方法对FCKeditor的标记都为content,在Action中用request.getParameter("content")即可。注意的是,这里获得的字符串是包括html标签的(即FCKeditor的值的HTML源代码)。
Q:FCKeditor中的按钮太多,只要其中一些该如何修改?
A:在fckconfig.js文件中修改,代码如下:
FCKConfig.ToolbarSets["Default"] = [
['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor','Image','Flash'],
['TextColor','BGColor','Table','Rule'],
['Style','FontFormat','FontName','FontSize']
] ;
将不用的删除即可。
Q:FCKedior中如何使用JavaScript来获得和设置其中的内容
A:<script type="text/javascript">
// 获得编辑器中的HTML内容
function getHTMLValue()
{
var oEditor = FCKeditorAPI.GetInstance("content");
var value = oEditor.GetXHTML(true);
alert(value);
}
// 获得编辑器中的文本内容
function getTextValue()
{
var oEditor = FCKeditorAPI.GetInstance("content");
var value = oEditor.EditorDocument.body.innerText;
alert(value);
}
// 设置编辑器中的内容
function initFCK()
{
var oEditor = FCKeditorAPI.GetInstance("content");
oEditor.SetHTML("<p><font color='red'>aaa</font></p>");
}
</script>
相关文章推荐
- fck编辑器下载及配置使用说明
- fck编辑器下载及配置使用说明
- jsp中如何使用FCK编辑器
- JSP版(utf8编码)的Ueditor百度文章编辑器配置以及使用说明
- Markdown编辑器使用说明——来自CSDN
- SVN: 使用说明(很基本和初级的使用说明)(转自:http://hua6884858.javaeye.com/blog/195801)
- JSP版(utf8编码)的Ueditor百度文章编辑器配置以及使用说明
- 如果是作为客户端的HTTP+JSON接口工程,没有JSP等view视图的情况下,使用Jersery框架开发绝对是第一选择。而在基于Spring3 MVC的架构下,对HTTP+JSON的返回类型也有很好
- 【爱上cocos2d-x之十八】Tiled瓦片地图编辑器的基本使用
- VxWorks6.6 pcPentium BSP 使用说明(一):基本概念 分类: vxWorks 2014-06-28 08:28 565人阅读 评论(0) 收藏
- iphone 开发开放库-ASIHTTPRequest类库简介和使用说明
- Vi编辑器的基本使用方法
- 在Eclipse里面使用其它编辑器打开jsp,css,js等文件
- jsp中使用FCKeditor编辑器组件的配置和优化
- HttpClient的基本使用
- 用CornerStone配置SVN,HTTP及svn简单使用说明
- 【错误解决】[Maven]使用Maven配置Jstl出现异常:The absolute uri: http://java.sun.com/jsp/jstl/core cannot...
- ASIHTTPRequest类库简介和使用说明
- [转载]ASIHTTPRequest类库简介和使用说明
- ASP.NET Web API(二):安全验证之使用HTTP基本认证