`
liukai
  • 浏览: 702158 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

springMVC下配置fckeditor2.6.6之一.如何整合fckeditor

    博客分类:
  • java
阅读更多
以前用的ckeditor,配置很方便.
后来要求实现上传图片的功能,发现必须要整合findeditor,跑去官网一看,没JAVA版本的..
只有返回到fckeditor上来.

先说下fckeditor如何配置吧
我用的fckeditor版本是2.6.6
其实网上教的很多配置都是剪切+拷贝的东西,内容雷同.
极度怀疑很多人到底手动配置过没.BS他们.

其实我的方法很简单.
去下个
fckeditor-java-demo-2.6.war

FCKeditor_2.6.6.zip

(网上说还要下java专门用的一个fckeditor-java-2.6-bin.zip ,在我的方法里不需要)
把fckeditor-java-demo-2.6.war包放在tomcat的webapps文件夹下
启动服务器,就会在webapps里获得一个名为fckeditor-java-demo-2.6的项目文件
(如果文件夹是空的说明下载的war包出问题了,去重新下载个,为了这个问题浪费了我好几个小时)
在浏览器输入
http://localhost:8080/fckeditor-java-demo-2.6

就能看到Demo了
打开webapps下的fckeditor-java-demo-2.6文件夹
直接把WEB-INF/lib下的所有jar包丢进自己的项目
把web.xml里所有的内容copy到自己项目里的web.xml里
 
		<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>
		<!-- Do not wrap this line otherwise Glassfish will fail to load this file -->
		<url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern>
	 


把fckeditor-java-demo-2.6\WEB-INF\classes里的fckeditor.properties
拷贝到自己项目里的相同位置,即WEB-INF\classes下

再解压FCKeditor_2.6.6.zip
得到一个fckeditor文件夹,放入根目录下
(其实fckeditor-java-demo-2.6的fckeditor也能用 但是少了个fckeditor.js,可能很多朋友不习惯),删点不用的东西
然后照着在根目录下创建userfiles/image文件夹
(还是能照着fckeditor-java-demo-2.6里的拷贝)
这样在配置上就完成了

然后是页面显示

在万能的fckeditor-java-demo-2.6里的jsp文件夹中
有许多JSP页面
很多都能直接拷贝.
比如sample02.jsp
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>FCKeditor - JSP Sample</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="robots" content="noindex, nofollow" />
		<link href="../sample.css" rel="stylesheet" type="text/css" />
		<link rel="shortcut icon" href="../fckeditor.gif"
				type="image/x-icon" />
		<script type="text/javascript">
			function FCKeditor_OnComplete(editorInstance) {
				window.status = editorInstance.Description;
			}
		</script>
	</head>
	<body>
	 
		<form action="sampleposteddata.jsp" method="post" target="_blank">
			<FCK:editor instanceName="EditorDefault">
				<jsp:attribute name="value">This is some <strong>sample text</strong> 
				</jsp:attribute>
			</FCK:editor>
			<br />
			<input type="submit" value="Submit" />
		</form>
	</body>
</html>

上面用的是fck的标签.注意最上面导入的
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %> 



如果你是用的非springMVC 那么到这 基本上就能成功显示了

如果你是用的springMVC 那么恭喜你,有可能你会报类似
15:52:51,105  WARN PageNotFound:1068 : No mapping found for HTTP request with URI [/cdpz/fckeditor/editor/fckeditor.html] in DispatcherServlet with name 'cdpz'

的错.
至于解决办法请看下章
http://liukai.iteye.com/blog/745901
BTW:
附件是FCKeditor_2.6.6.zip和fckeditor-java-demo-2.6.war
方便大家下载了
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics