To use the text editor, select FCKeditor. The following configuration describes the environment:
Windows XP
Myeclipse6.0ga
Fckeditor2.6.3
Fckeditor2.3 1. Download
Official download homepage: http://www.fckeditor.net/download/. fckeditor_2.6.3.zip is used.
And FCKeditor-2.3 version
2. Deployment
In this example, webroot is used as the application root path. The directory structure after deployment is shown in: 1、fckeditor_2.5.1.zip decompress and copy the FCKeditor folder to/webroot /.
2、fckeditor-2.3.zip unzip, copy commons-fileupload.jar and FCKeditor-2.3.jar to/webroot/WEB-INF/lib/
3. Modify the/webroot/WEB-INF/Web. xml file and add the following content:
- <Servlet>
- <Servlet-Name> connector </servlet-Name>
- <Servlet-class> com. fredck. FCKeditor. connector orservlet </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> true </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>/FCKeditor/connector </url-pattern>
- </Servlet-mapping>
- <Servlet-mapping>
- <Servlet-Name> simpleuploader </servlet-Name>
- <URL-pattern>/FCKeditor/simpleuploader </url-pattern>
- </Servlet-mapping>
4. Modify/webroot/FCKeditor/fckconfig. js as follows:
- Fckconfig. linkbrowserurl = fckconfig. basepath + 'filemanager/Browser/default/browser.html? Connector =/FCKeditor/connector ';
- Fckconfig. imagebrowserurl = fckconfig. basepath + 'filemanager/Browser/default/browser.html? Type = Image & connector =/FCKeditor/connector ';
- Fckconfig. flashbrowserurl = fckconfig. basepath + 'filemanager/Browser/default/browser.html? Type = flash & connector =/FCKeditor/connector ';
- Fckconfig. linkuploadurl = '/FCKeditor/simpleuploader? Type = FILE ';
- Fckconfig. imageuploadurl = '/FCKeditor/simpleuploader? Type = image ';
- Fckconfig. flashuploadurl = '/FCKeditor/simpleuploader? Type = flash ';
Note::
(1) Steps 3 and 4 configure file browsing and uploading. The servlet <URL-pattern> in Web. xml must be consistent with the URL reference in fckconfig. js;
(2) the premise of normal operation in this example is that webroot is deployed as the root path. If a virtual path is set, the servlet cannot be found.
Iv. Use
This example uses the most direct js method. The example contains web-INF/fckdemo. jsp:
- <% @ Page contenttype = "text/html; charset = GBK" %>
- <HTML>
- <Head>
- <Title> FCKeditor test </title>
- <SCRIPT type = "text/JavaScript" src = "FCKeditor/FCKeditor. js"> </SCRIPT>
- </Head>
- <Body>
- <Form action = "fckdemo. jsp" method = "Post">
- <%
- String content = request. getparameter ("content ");
- If (content! = NULL ){
- Content = content. replaceall ("/R/N ","");
- Content = content. replaceall ("/R ","");
- Content = content. replaceall ("/N ","");
- Content = content. replaceall ("/"","'");
- } Else {
- Content = "";
- }
- %>
- <Table width = 100%>
- <Tr>
- <TD colspan = 4 style = 'text-align: Center' width = 100% Height = 50px>
- <Span>
- <SCRIPT type = "text/JavaScript">
- VaR ofckeditor = new FCKeditor ('content'); // The input parameter is the name of the form element (input or textarea generated by FCKeditor ).
- Ofckeditor. basepath = 'fckeditor/'; // specify the root path of FCKeditor, that is, the path of FCKeditor. js.
- Ofckeditor. Height = '20140901 ';
- Ofckeditor. toolbarsets = 'Demo'; // specifies the toolbar. Note that toolbarsets
- Ofckeditor. value = "<% = content %>"; // Default Value
- Ofckeditor. Create ();
- </SCRIPT>
- </Span>
- </TD>
- </Tr>
- <Tr> <TD align = center> <input type = "Submit" value = "Submit"> </TD> </tr>
- <Tr> <TD> </tr>
- <Tr> <TD> values (saved to the database): </TD> </tr>
- <Tr> <TD style = "padding: 10px;"> <% = content %> </TD> </tr>
- </Table>
- </Form>
- </Body>
- </Html>
5. configuration file fckconfig. js
1. defaultlanguage: default language, which can be changed to "ZH-CN"
2. Custom toolbar: you can modify or add toolbarsets, for example:
Fckconfig. toolbarsets ["Demo"] = [
['Bold ', 'italic', '-', 'orderedlist', 'unorderedlist', '-', 'link', 'unlink ','-', 'textcolor', 'bgcolor', '-', 'style', '-', 'image', 'flash', 'table']
];
3. entermode and shiftentermode: line feed of "Carriage Return" and "Shift + carriage return". The optional mode is prompted for comments.
4. editorareacss: editing area Style File
5. Other parameters (for conversion ):
- Autodetectlanguage = true/false automatic language Detection
- Basehref = "" Relative Link base address
- Contentlangdirection = "LTR/RTL" default text direction
- Contextmenu = string array, right-click the menu content
- Customconfigurationspath = "" custom configuration file path and name
- DEBUG = true/false whether to enable debugging. In this way, when fckdebug. Output () is called, the content is output in the debugging window.
- When enablesourcexhtml = true/false is true, when the code page is switched from the visual interface to the code page, the HTML is processed as XHTML.
- Enablexhtml = true/false: Can I use XHTML to replace HTML?
- Fillemptyblocks = true/false use this function to replace empty block-level elements with spaces.
- Fontcolors = "" sets the text color list when the color picker is displayed
- Fontformats = "" set the name displayed in the text format list
- Fontnames = "" fontnames
- Fontsizes = "" font size in the font size list
- Forcepasteasplaintext = true/false force paste to plain text
- Forcesimpleampersand = true/false do not convert & symbol to XML Entity
- Formatindentator = "" specifies the characters used to indent the code in the source code format.
- Formatoutput = true/false: whether to automatically format the code when output content
- Formatsource = true/false whether to automatically format the code when switching to the Code view
- Fullpage = true/false: whether to allow editing of the entire HTML file or only the content between the bodies
- Geckousespan = true/false: whether to allow the span flag to replace the B, I, u flag
- Iespelldownloadurl = "" download the spelling checker URL
- Imagebrowser = true/false: whether to allow browsing of server functions
- Imagebrowserurl = "" the URL that runs when browsing the server
- Imagebrowserwindowheight = "" image browser window height
- Imagebrowser1_wwidth = "" image browser window width
- Linkbrowser = true/false: whether to allow browsing the server when a link is inserted
- Linkbrowserurl = "" browsing the server URL when inserting a link
- Linkbrowserwindowheight = "" link target browser window height
- Linkbrowserdomainwwidth = "" link target browser window width
- Plugins = Object Registration plug-in
- Pluginspath = "" plug-in folder
- Showborders = true/false merge border
- Skinpath = "" skin folder location
- Smileycolumns = 12 Number of columns in the graphic operator window
- Smileyimages = String Array array of image file names in the graphic character window
- Smileypath = "" folder path
- Smileywindowheight tumbler window height
- Smiley1_wwidth tumbler window width
- Spellchecker = "iespell/spellerpages" set the spelling checker
- When startupfocus = true/false is enabled, focus to the editor.
- Stylesxmlpath = "" set the location of the XML file that defines the CSS style list
- Tabspaces = 4 Number of space characters generated by the tab key
- Toolbarcancollapse = true/false: whether to enable or disable the toolbar.
- Toolbarsets = the toolbar set can be used for objects.
- Toolbarstartexpanded = true/false enable indicates whether to expand a toolbar.
- Usebroncarriagereturn = true/false when you press enter, whether to generate a br mark or a P or Div mark
6. Custom styles
The style option in the toolbar is generated by the configuration file specified by fckconfig. JS:
Fckconfig. stylesxmlpath = fckconfig. editorpath + 'fckstyles. xml ';
You can modify the fckstyles. xml custom style.
Reference: http://www.blogjava.net/fastunit/archive/2008/02/18/180525.html