在java开发中用得比较多的文本编辑器一般采用fckeditor。
现就fckeditor在JSP中的调用归纳如下:
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
1、FCKeditor自定义标签在JSP页面调用:
1)首先在web.xml中做简单的配置,配置文件内容如下,直接copy到web.xml即可:
<servlet>
<servlet-name>Connector</servlet-name>
<servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
<init-param>
<param-name>baseDir</param-name>
<param-value>/UserFiles/</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SimpleUploader</servlet-name>
<servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
<init-param>
<param-name>baseDir</param-name>
<param-value>/UserFiles/</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>enabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsFile</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsFile</param-name>
<param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsImage</param-name>
<param-value>jpg|gif|jpeg|png|bmp</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsImage</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsFlash</param-name>
<param-value>swf|fla</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsFlash</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>/include/fckeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SimpleUploader</servlet-name>
<url-pattern>/include/fckeditor/editor/filemanager/upload/simpleuploader</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>/include/fckeditor</taglib-uri>
<taglib-location>/WEB-INF/FCKeditor.tld</taglib-location>
</taglib>
2)JSP页面要引入FCKeditor.tld这个文件,该文件放在WEB-INF文件夹下,页面引入代码如下:
<%@ taglib uri="/WEB-INF/FCKeditor.tld" prefix="fck" %>
3)实现代码如下:
<tr>
<td class="tr_title_edit"><label for="f_content">内容</label></td>
<td class="tr_content_edit" colspan="3">
<fck:editor id="f_content" basePath="/dpsafe/include/fckeditor/"
height="500"
width="100%"
skinPath="/dpsafe/include/fckeditor/editor/skins/default/"
toolbarSet="Default"
imageBrowserURL="/dpsafe/include/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
linkBrowserURL="/dpsafe/include/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
flashBrowserURL="/dpsafe/include/fckeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
imageUploadURL="/dpsafe/include/fckeditor/editor/filemanager/upload/simpleuploader?Type=Image"
linkUploadURL="/dpsafe/include/fckeditor/editor/filemanager/upload/simpleuploader?Type=File"
flashUploadURL="/dpsafe/include/fckeditor/editor/filemanager/upload/simpleuploader?Type=Flash">
</fck:editor>
</td>
</tr>
我将fckeditor单独入在一个公用的include文件夹中,以便任何要用到该编辑器的页面都能够引用它,节省空间,维护方便。
到此fckeditor编辑器也就能够使用了。
2、 在页面写这么多东西,感觉太复杂了一点,要写配置还要引用文件;用JS调用就相对要简单些,具体介绍如下:
1)引入fckeditor.js文件,具体代码如下:
<script language="javascript" type="text/javascript" src="<%=basePath%>/include/fckeditor/fckeditor.js"></script>
2) 页面具体的代码调用如下:
<tr>
<td class="tr_title_edit"><label for="f_content">内容</label></td>
<td class="tr_content_edit" colspan="3">
<script type="text/javascript">
<!--
var sBasePath = "<%=basePath%>/include/fckeditor/";
var oFCKeditor = new FCKeditor( 'f_content' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Height = 500 ;
oFCKeditor.Create() ; //调用它的create()方法来直接在JSP嵌入FCKeditor编辑器
//-->
</script>
</td>
</tr>
另一种调用FCKeditor编辑器的方法的简单区别是:
<td>
<textarea id="f_content" name="f_content" style="WIDTH: 100%; HEIGHT: 400px">input</textarea>
<script type="text/javascript">
var sBasePath = "<%=basePath%>/include/fckeditor/";
var oFCKeditor = new FCKeditor( 'f_content' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Height = 500 ;
oFCKeditor.ReplaceTextarea(); //替换文本域
</script>
</td>
3、 修改页面如何实现,只需修改几个部分即可,具体如下:
1)JSP修改页面只需在增加页面的基础上加一句代码:
<fck:editor id="f_content" basePath="/dpsafe/include/fckeditor/"
height="500"
width="100%"
skinPath="/dpsafe/include/fckeditor/editor/skins/default/"
toolbarSet="Default"
imageBrowserURL="/dpsafe/include/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
linkBrowserURL="/dpsafe/include/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
flashBrowserURL="/dpsafe/include/fckeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
imageUploadURL="/dpsafe/include/fckeditor/editor/filemanager/upload/simpleuploader?Type=Image"
linkUploadURL="/dpsafe/include/fckeditor/editor/filemanager/upload/simpleuploader?Type=File"
flashUploadURL="/dpsafe/include/fckeditor/editor/filemanager/upload/simpleuploader?Type=Flash">
<%=pubDTO.getContent() %>
</fck:editor>
2)JS修改方法如下:
<tr>
<td class="tr_title_edit"><label for="f_content">内容</label></td>
<td class="tr_content_edit" colspan="3">
<script type="text/javascript">
var sBasePath = "<%=basePath%>/include/fckeditor/";
var oFCKeditor = new FCKeditor( 'f_content' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Height = 500 ;
oFCKeditor.Value = '<%=f_content%>' ;
oFCKeditor.Create() ;
//-->
</script>
</td>
</tr>
分享到:
相关推荐
Fck文本编辑器 FCKeditor fckeditor 表情 格式 可以修改成QQ表情只需要改表情目录下的文件就可以加入自己喜爱的表情 官方源码 配置说明
FCKeditor & FCKeditor.java & fck-faces
fckeditor-java-2.6 源代码 FCK fckeditor-java-2.6 源代码 FCK fckeditor-java-2.6 源代码 FCK fckeditor-java-2.6 源代码 FCK
fck的整合,上传,例子有需要的包!fck的整合,上传,例子有需要的包!fck的整合,上传,例子有需要的包!
3.2 在Jsp中通过自定义标签创建: 9 3.3 FCKeditor API 调用 10 3.4 适时打开编辑器 10 4 修改FCKeditor的配置: 11 4.1 方法一:修改fckconfig.js 文件 11 4.2 方法二:使用一个额外的配置文件覆盖默认配置 11 4.3 ...
java fck例子
把页面中的下面代码中 <FCK:editor id="infoContent" basePath="../../FCKeditor/" width="822" height="300" skinPath="../../FCKeditor/editor/skins/silver/" defaultLanguage="zh-cn" . . . </FCK:editor> ...
FCK在线编辑器 FOR JAVA 先,FCKEDITOR的性能是非常好的,用户只需很少的时间就可以载入FCKEDITOR所需文件.对于其他在线编辑器来说,这几乎是个很难解决的难题,因为在开启编辑器时需要装载太多的文件
首先去下载FCKEditor2.6.3(当然本文编写的时候,这个是最新版本,也许你现在看到的已经是更新的版本了,... 第二是FCKeditor.Java(fckeditor-java-2.4.1-bin.zip),就是在Java代码中使用FCKEditor的相关工具类;
fckeditor 在java中的配置及图片的上传[案例]
FCK FCKeditor_2.6.6 DLL 文件
此视频教程、包含fck(fckeditor、ckeditor类似)工具的两种调用方式和安装教程
fck嵌入JAVA java使用FCK
FCKeditor编辑器在JAVA中的使用与配置
java 中导入在线编辑器,可以使用word样式的编辑,所见即所得,支持图片和Flash,工具栏可自由配置,使用简单 可直接导入Myeclipse 配置运行。里面包括配置压缩包,以及完整实例。
FCK控件 fckeditor,强大插件,最完整。 即插即用
这是一个Myeclipse小项目 FCK
fckeditor的src文件,解决fck自定义问题、中文乱码等问题的源文件,修改其中文件再编译替换jar。
jsp 程序调用fckeditor2.6 版本的 小例子 本人发现fckeditor2.6加 fckeditor for 2.3 的时候在上传中文文件的时候会出现乱码 所以本人就小改了一下 fckeditor2.3的源代码,以时间重命名上传文件名,没什么技术...
这个是一个我修改过的fckeditor for jsp 的jar包的源代码,是fckeditor-2.3的,我修改了ConnectorServlet.java和SimpleUploaderServlet.java两个文件 我在这两个文件中都是加了一个静态变量encoding,private static...