大家知道FCKeditor是一款强大的富文本框控件,可能很多人还不知道如何把她加入到项目中,或者知道但是已经忘记了,没关系,我们在这学习学习,复习复习。
1、下载fckeditor
地址:http://ckeditor.com/
2、导入jar包和文件
fckeditor-java-core-2.6.jar
imageinfo-1.9.jar
fckeditor下的js、html等文件,可以删除所有以"_"开头的文件夹
3、导入标签和使用标签
<%@ taglib uri="http://java.fckeditor.net" prefix="fck" %>
<fck:editor instanceName="movInfo.info"></fck:editor>
<fck:editor inputName="movInfo.info" instanceName="movInfomation" toolbarSet="Basic"></fck:editor>
4、自定义工具栏
配置fckconfig.js
FCKConfig.ToolbarSets["Default"] = [
['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],
'/',
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote','CreateDiv'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
'/',
['Style','FontFormat','FontName','FontSize'],
['TextColor','BGColor'],
['FitWindow','ShowBlocks','-','About'] // No comma for the last row.
] ;
FCKConfig.ToolbarSets["Basic"] = [
['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About']
] ;
说明:
instanceName 就是相当去控件的name
toolbarSet 就是设置你需要使用的功能样式,在上面定义的,当然你也可以自己增加新的
<fck:editor instanceName="movInfo.info" toolbarSet="Basic"></fck:editor>
5、配置文件上传(与Struts2共存)
由于大部分情况下我们在配置Struts2的过滤器的时候都是用*,所以这边我要绕过她,在这里写一个过滤器先。
package com.main.movie.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
public class FckUploadFilter implements Filter {
private String DispatcherUrl;
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httprequest = (HttpServletRequest) request;
//其实就是根据传的参数来判断在做什么
if (httprequest.getParameter("Type") != null && httprequest.getParameter("Type").equals("Image")) {
//跳转到fck用的页面,不执行后面的过滤器
httprequest.getRequestDispatcher(DispatcherUrl).forward(request, response);
} else {
//否则才继续执行过滤器,所以在配置web.xml的时候要把该过滤器放在struts2的前面
chain.doFilter(request, response);
}
}
public void init(FilterConfig filterConfig) throws ServletException {
DispatcherUrl = filterConfig.getInitParameter("DispatcherUrl");
}
}
配置struts.xml,加入下面的代码片段
<constant name="struts.multipart.saveDir" value="/tmp"></constant>
6、配置web.xml
注意FCK的过滤器一定要配置在Struts2过滤器的前面
<!-- FckUploadFilter -->
<filter>
<filter-name>FckUploadFilter</filter-name>
<filter-class>com.main.movie.filter.FckUploadFilter</filter-class>
<init-param>
<param-name>DispatcherUrl</param-name>
<param-value>/fckeditor/editor/filemanager/connectors/</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>FckUploadFilter</filter-name>
<url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern>
</filter-mapping>
<!-- Fckeditor -->
<servlet>
<servlet-name>ConnectorServlet</servlet-name>
<servlet-class>net.fckeditor.connector.ConnectorServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ConnectorServlet</servlet-name>
<url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern>
</servlet-mapping>
7、配置fckeditor.properties(就创建这个文件然后把下面的代码复制进去就行了)
# default allowed extensions settings
connector.resourceType.file.extensions.allowed = 7z|aiff|asf|avi|bmp|csv|doc|fla|flv|gif|gz|gzip|jpeg|jpg|mid|mov|mp3|mp4|mpc|mpeg|mpg|ods|odt|pdf|png|ppt|pxd|qt|ram|rar|rm|rmi|rmvb|rtf|sdc|sitd|swf|sxc|sxw|tar|tgz|tif|tiff|txt|vsd|wav|wma|wmv|xls|xml|zip
connector.resourceType.image.extensions.allowed = bmp|gif|jpeg|jpg|png
connector.resourceType.flash.extensions.allowed = swf|fla
connector.resourceType.media.extensions.allowed = aiff|asf|avi|bmp|fla|flv|gif|jpeg|jpg|mid|mov|mp3|mp4|mpc|mpeg|mpg|png|qt|ram|rm|rmi|rmvb|swf|tif|tiff|wav|wma|wmv
# default resource type paths
connector.resourceType.file.path = /file
connector.resourceType.image.path = /image
connector.resourceType.flash.path = /flash
connector.resourceType.media.path = /media
# Due to security issues with Apache modules, it is recommended to leave this
# setting enabled.
connector.forceSingleExtension = true
# base URL path for the userfiles
connector.userFilesPath = /fckupload
# base system path on the backend for the userfiles
connector.userFilesAbsolutePath = /fckupload
# Instructs the Connector to check, if the uploaded image is really one
connector.secureImageUploads = true
# directory of the editor relative to the context root
fckeditor.basePath = /fckeditor
# default height of the editor
fckeditor.height = 200
# default toolbar set of the editor
fckeditor.toolbarSet = Default
# default width of the editor
fckeditor.width = 100%
# default implementations
connector.impl = net.fckeditor.connector.impl.ContextConnector
connector.userActionImpl = net.fckeditor.requestcycle.impl.EnabledUserAction
connector.userPathBuilderImpl = net.fckeditor.requestcycle.impl.ContextPathBuilder
localization.localeResolverImpl = net.fckeditor.localization.impl.AcceptLanguageHeaderResolver
分享到:
相关推荐
对fckeditor 文件上传功能的修改 1.文件上传绝对路径配置 2.文件上传按上传日期保存 3.浏览上传图片文件和flash文件添加预览功能
包括fckeditor2.6.4+fckeditor-java-2.4.1配置所需资源包及fckeditor-java-2.4.1源码和配置说明文档。 配置中解决了中文乱码,并为上传文件自动创建日期文件夹。
fckeditor-java-core-2.4.jar 中文乱码 文件重名 中文文件夹
4、限制上传文件大小(这个也设置了可以自主修改,找到fckeditor.properties文件最后的地方,# maxFileSize 1M connector.resource.maxFileSize=1048576,单位是字节) 5、把里边没用的文件都删除了,呵呵 其中的...
fckeditor-java-core-2.4.jar。上传下载库文件
CKEditor FCKEditor 使用-集成 CKFinder(上传文件、浏览文件)
FCKeditor提供了非常强大和易用的文件上传功能,但是默认配置里,文件上传功能不可用,这是基于安全的考虑。但我认为访问安全性控制应该由程序来做,不应由控件来做。 在文件config.ascx中,修改CheckAuthentication...
修改文件径fckeditor--ditor--dialog--fck_image中的fck_image.js、fckconfig.js等等花时间琢磨一下. 其中还有我自己改写的公共类,带"image"标识的文件,希望大家都详细看看,改过的地方很多,就不例举了。希望大家...
FCKeditor(jsp版本)目录文件,FCKeditor.jar包,增加FCKeditor添加FLV视频功能和FCKeditor上传文件自动更名功能 1.修正了上传中文文件乱码的问题,上传之后会重命名文件 2.修正了不能上传FLV视频的问题
采用2.6.4版本,彻底解决fckeditor(jsp版)上传中文文件乱码问题。 使用Tomcat应用服务器时,为了更好的支持URL地址中的中文参数问题.需要在tomcat进行如下设置: 需要修改server.xml文件的如下行: maxThreads=...
将Fckeditor 里的保留文件拷贝到网站根目录文件夹里,即/ictech/下 /fcktemplates.xml /fckstyles.xml /fckeditor_php5.php /fckeditor_php4.php /fckeditor.php /fckeditor.js /fckconfig.js /editor/ fckeditor....
5.1 开启和关闭文件上传功能(fckconfig.js) 19 5.2 文件上传的基本使用 19 5.3 上传中文文件名的文件会出现乱码 20 5.4 创建中文名目录会出现乱码 21 5.5 引用中文名文件的图片不能正常显示 21 5.6 控件允许上传的...
FCKeditor功能还真是强大,但它好像对Jsp不大敏感,网上介绍的文章也少。赶上最近要研究用FCKeditor上传图片,刚发现了几篇,加上自己的研究成果,赶快总结一下。 先去下载一个FCKeditor,再下一个FCKeditor.java ...
本项目是根据itcast 和网上找的一些资料,自己写出来的一个fckeditor 项目,希望对大家有用,内含我所用到的所有文件,包括 FCKeditor_2.6.6.tar.gz 、fckeditor-java-2.4-bin.zip、fckeditor-java-2.4-src.zip、slf...
手动 扩展Fckeditor 上传文件 功能
FCKeditor 2.6.3网页编辑器最新版(PHP有选择本地文件上传的功能)
修正了FCKeditor的文件上传,用户可以自己修改FCKeditor\editor\filemanager\browser\default\FileUploadInFCK.aspx.cs文件中的SaveFile方法。灵活的实现自己对上传文件的管理。需要配合AjaxPro.2.dll
为fckeditor添加多文件批量上传组件,使fckeditor编辑器实现多图上传的功能,该文档以在本地测试成功,可直接嵌入程序使用。
Exploiting PHP Upload Module ofBypassing File-type CheckExploiting PHP Upload Mo
但是客户一直说上传的文件多了,想找刚才上传的文件有时会很费时间。于是在网上找关于“fckEditor显示文件按日期时间排序”的方法,却一直没有找到。只有自己动手更改文件了。 详情:...