日期:2014-05-16 浏览次数:20402 次
添加jar包:
fckeditor-java-2.4.1/fckeditor-java-core-2.4.1.jar
fckeditor-java-2.4.1/lib/commons-fileupload-1.2.1.jar
fckeditor-java-2.4.1/lib/commons-io-1.3.2.jar
fckeditor-java-2.4.1/lib/slf4j-api-1.5.2.jar
sfckeditor-java-demo-2.4.1.war/WEB-INF/lib/slf4j-simple-1.5.2.jar
注:fckeditor-java-2.4.1/lib/slf4j-api-1.5.2.jar这个包只是个接口类,必需有实现类。我用的是sfckeditor-java-demo-2.4.1.war下WEB-INF/lib/slf4j-simple-1.5.2.jar
?
例子:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<html>
? <head>
??? <title>My JSP 'index.jsp' starting page</title>
? </head>
? ??? <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
? ???
? ??? <script type="text/javascript">
? ??? ??? //第一种方法
??? ??? var oFCKeditor = new FCKeditor('FCKeditor1');
??? ??? oFCKeditor.BasePath = "<%=request.getContextPath()%>/fckeditor/";
??? ??? oFCKeditor.Width = "70%";
??? ??? oFCKeditor.Height = "150";
??? ??? oFCKeditor.Value = "default"
??? ??? oFCKeditor.Create();
??? </script>
???
??? <script type="text/javascript">
??? ???
??? ??? window.onload = function() {
??? ??? ??? //第二种方法
??? ??? ??? var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
??? ??? ??? oFCKeditor.BasePath = "<%=request.getContextPath()%>/fckeditor/" ;
??? ??? ??? oFCKeditor.ReplaceTextarea() ;
??? ??? ??? //第三种方法
??? ??? ??? var div = document.getElementById("myFCKeditor");
??? ??? ??? var fck = new FCKeditor("myFCKeditor");
??? ??? ??? fck.BasePath = "<%=request.getContextPath()%>/fckeditor/" ;
??? ??? ??? div.innerHTML = fck.CreateHtml();
??? ??? }
??? </script>
???
? <body>
? ??? t<br/>Method 2<br/>
??? <textarea rows="4" cols="60" name="MyTextarea" style="display:none">default</textarea>
???? <br/>Method 3? <br>
???? <div id="myFCKeditor"> </div>
???? <br/>Method 4? 用JSP自定义标签输出Fckeditor<br>
???? <FCK:editor instanceName="myDditor" basePath="/fckeditor" value="default"/>
? </body>
</html>