FCKeditor在线编辑器

FCKeditor在线编辑器
FCKeditor 这个开源的HTML 文本编辑器可以让web 程序拥有如MS Word 这样强大的编辑功
FCKeditor官司方网址:http://www.fckeditor.net/

FCKeditor在线DEMO:http://www.fckeditor.net/demo

FCKeditor下载直址:http://www.fckeditor.net/download 最新版已经是2.6了。

 在项目中使用FCKeditor在线编辑器:
(1) 新建一个WEB工程;
(2) 解压FCKeditor_2.6.zip包,将其中的editor文件夹复制到项目中去;
(3) 解压FCKeditor_2.6.zip包,将其中的fckconfig.js、fckeditor.js、fckstyles.xml、fcktemplates.xml赋值到项目中的WebRoot目录下面;
(4) 将FCKeditor.jar文件复制到WebRoot\WEB-INF\lib目录;
(5) 将FCKeditor.tld文件复制到WEB-INF下面;
(6) 修改web.xml配置文件中的信息,如下;
<!-- fckeditor start -->

Java代码 复制代码
  1. <servlet>   
  2.         <servlet-name>Connector</servlet-name>   
  3.         <servlet-class>   
  4.             com.fredck.FCKeditor.connector.ConnectorServlet   
  5.         </servlet-class>   
  6.         <init-param>   
  7.             <param-name>baseDir</param-name>   
  8.             <param-value>/UserFiles/</param-value>   
  9.         </init-param>   
  10.         <init-param>   
  11.             <param-name>debug</param-name>   
  12.             <param-value>true</param-value>   
  13.         </init-param>   
  14.         <load-on-startup>1</load-on-startup>   
  15.     </servlet>   
  16.     <servlet>   
  17.         <servlet-name>SimpleUploader</servlet-name>   
  18.         <servlet-class>   
  19.             com.fredck.FCKeditor.uploader.SimpleUploaderServlet   
  20.         </servlet-class>   
  21.         <init-param>   
  22.             <param-name>baseDir</param-name>   
  23.             <param-value>/UserFiles/</param-value>   
  24.         </init-param>   
  25.         <init-param>   
  26.             <param-name>debug</param-name>   
  27.             <param-value>false</param-value>   
  28.         </init-param>   
  29.         <init-param>   
  30.             <param-name>enabled</param-name>   
  31.             <param-value>true</param-value>   
  32.         </init-param>   
  33.         <init-param>   
  34.             <param-name>AllowedExtensionsFile</param-name>   
  35.             <param-value></param-value>   
  36.         </init-param>   
  37.         <init-param>   
  38.             <param-name>DeniedExtensionsFile</param-name>   
  39.             <param-value>   
  40.                 php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi   
  41.             </param-value>   
  42.         </init-param>   
  43.         <init-param>   
  44.             <param-name>AllowedExtensionsImage</param-name>   
  45.             <param-value>jpg|gif|jpeg|png|bmp</param-value>   
  46.         </init-param>   
  47.         <init-param>   
  48.             <param-name>DeniedExtensionsImage</param-name>   
  49.             <param-value></param-value>   
  50.         </init-param>   
  51.         <init-param>   
  52.             <param-name>AllowedExtensionsFlash</param-name>   
  53.             <param-value>swf|fla</param-value>   
  54.         </init-param>   
  55.         <init-param>   
  56.             <param-name>DeniedExtensionsFlash</param-name>   
  57.             <param-value></param-value>   
  58.         </init-param>   
  59.         <load-on-startup>1</load-on-startup>   
  60.     </servlet>   
  61.   <servlet>   
  62.     <description>This is the description of my J2EE component</description>   
  63.     <display-name>This is the display name of my J2EE component</display-name>   
  64.     <servlet-name>PostArticle</servlet-name>   
  65.     <servlet-class>servlet.PostArticle</servlet-class>   
  66.   </servlet>   
  67.   
  68.   
  69.     <servlet-mapping>   
  70.         <servlet-name>Connector</servlet-name>   
  71.         <url-pattern>   
  72.             /FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector   
  73.         </url-pattern>   
  74.     </servlet-mapping>   
  75.     <servlet-mapping>   
  76.         <servlet-name>SimpleUploader</servlet-name>   
  77.         <url-pattern>   
  78.             /FCKeditor/editor/filemanager/upload/simpleuploader   
  79.         </url-pattern>   
  80.     </servlet-mapping>   
  81.   <servlet-mapping>   
  82.     <servlet-name>PostArticle</servlet-name>   
  83.     <url-pattern>/servlet/post</url-pattern>   
  84.   </servlet-mapping>  
<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>true</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>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>PostArticle</servlet-name>
    <servlet-class>servlet.PostArticle</servlet-class>
  </servlet>


	<servlet-mapping>
		<servlet-name>Connector</servlet-name>
		<url-pattern>
			/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector
		</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>SimpleUploader</servlet-name>
		<url-pattern>
			/FCKeditor/editor/filemanager/upload/simpleuploader
		</url-pattern>
	</servlet-mapping>
  <servlet-mapping>
    <servlet-name>PostArticle</servlet-name>
    <url-pattern>/servlet/post</url-pattern>
  </servlet-mapping>

<!-- fckeditor end -->
(7) 在JSP页面中使用,如:test.jsp
首先要在报头中加入

Java代码 复制代码
  1. <%@ taglib uri="http://fckeditor.net/tags-fckeditor" prefix="f"%>  
<%@ taglib uri="http://fckeditor.net/tags-fckeditor" prefix="f"%>

还要注意basepath及path的设置

Java代码 复制代码
  1. <%   
  2. String path = request.getContextPath();   
  3. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";   
  4. %>   
  5.   
  6.   <body>   
  7.     <form action="servlet/post" method="post">   
  8.         title:<input type="text" name="title"><br>   
  9.         <f:editor id="content"  basePath='<%=path + "/FCKeditor/"%>'  
  10.                 imageBrowserURL='<%=path   
  11.                             + "/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"%>'   
  12.                 linkBrowserURL='<%=path   
  13.                             + "/FCKeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"%>'   
  14.                 flashBrowserURL='<%=path   
  15.                             + "/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"%>'   
  16.                 imageUploadURL='<%=path   
  17.                             + "/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Image"%>'   
  18.                 linkUploadURL='<%=path   
  19.                             + "/FCKeditor/editor/filemanager/upload/simpleuploader?Type=File"%>'   
  20.                 flashUploadURL='<%=path   
  21.                             + "/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Flash"%>'>   
  22.            
  23.            
  24.             </f:editor>   
  25.             <input type="submit">   
  26.     </form>   
  27.   </body>  
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

  <body>
    <form action="servlet/post" method="post">
    	title:<input type="text" name="title"><br>
    	<f:editor id="content"  basePath='<%=path + "/FCKeditor/"%>'
				imageBrowserURL='<%=path
							+ "/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"%>'
				linkBrowserURL='<%=path
							+ "/FCKeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"%>'
				flashBrowserURL='<%=path
							+ "/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"%>'
				imageUploadURL='<%=path
							+ "/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Image"%>'
				linkUploadURL='<%=path
							+ "/FCKeditor/editor/filemanager/upload/simpleuploader?Type=File"%>'
				flashUploadURL='<%=path
							+ "/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Flash"%>'>
		
		
			</f:editor>
			<input type="submit">
    </form>
  </body>

 

你可能感兴趣的:(jsp,servlet,fckeditor,Flash,asp.net)