Use and configuration of FCKeditor in JAVA

Source: Internet
Author: User

Prepare fckeditor_2.4.2.zip [main package of the component] And FCKeditor. Java 2.3.zip [the jar for tag library and Image Upload is provided here ]. These can be downloaded on the http://www.fckeditor.net website! Configuration 1. create a project compass and create a new folder FCKeditor under the WebRoot folder (used to store FCKeditor-related files. Remember to use the same case, because if you need to change the file, there will be more files, and you are not sure whether the change is complete.) 2. set the editor folder and fckconfig in the FCKeditor_2.4.2 package. js, fckeditor. js, fckstyles. xml, fcktemplates. put the four xml files in the FCKeditor directory of the project. 3. set FCKeditor. java-2.3.zip package \ web \ WEB-INF \ lib under the two jar files to the project WebRoot \ WEB-INF \ lib directory 4. set FCKeditor. FCKeditor under \ src in Java -2.3.zip. tld file to the project's WebRoot \ WEB-INF directory 5. create a new UserFiles folder under the WebRoot directory, and create four folders: Image, Flash, File, and Media. They are used to store uploaded images, animations, files, and Media files. 6. modify fckconfig. js component configuration file [description, you can search the information before the equal sign in the configuration file to determine A change]: A, FCKConfig. skinPath = FCKConfig. basePath + 'Skins/silver/'; this is the style template of the component. Which style do you want to use? This is changed according to your preferences. B, FCKConfig. defaultLanguage = 'zh-cn'; it is used to determine the language you want to use and set it to the simplified Chinese. C. Change the file browsing path: FCKConfig. linkBrowserURL = FCKConfig. basePath + "filemanager/browser/default/browser.html? Connector = connectors/jsp/connector "; FCKConfig. ImageBrowserURL = FCKConfig. BasePath +" filemanager/browser/default/browser.html? Type = Image & Connector = connectors/jsp/connector "; FCKConfig. FlashBrowserURL = FCKConfig. BasePath +" filemanager/browser/default/browser.html? Type = Flash & Connector = connectors/jsp/connector "; block the corresponding information and use the above D to change the path of the uploaded file FCKConfig. linkUploadURL = FCKConfig. basePath + 'filemanager/upload/simpleuploader? Type = FILE'; FCKConfig. FlashUploadURL = FCKConfig. BasePath + 'filemanager/upload/simpleuploader? Type = Flash '; FCKConfig. ImageUploadURL = FCKConfig. BasePath + 'filemanager/upload/simpleuploader? Type = image'; block the corresponding information and use the original text above from webmaster www. software8.co/7. modify web. add the following content to the xml file: in FCKeditor. java-2.3.zip package contains a web \ WEB-INF \ WEB. XML: copy the content in this node to the corresponding location in your project. It is worth noting that: <servlet-name> Connector </servlet-name> <servlet-class> com. fredck. FCKeditor. connector. connectorServlet </servlet-class> <init-param> <param-name> baseDir </param-name> <! -- This is the file browsing path. You can only modify the path, but remember not to change it to "/[project name]/UserFiles/" because it is already running in the root directory of the project, therefore, if you want to change the default file directory to the webroot \ upload directory, you need to change it to:/upload /, you can --> <param-value>/UserFiles/</param-value> </init-param> <servlet-name> SimpleUploader </servlet-name> <servlet-class> com. fredck. FCKeditor. uploader. simpleUploaderServlet </servlet-class> <init-param> <param-name> baseDir </param-name> <! -- This is the file upload path. You can only modify the file, but do not change it to "/[project name]/UserFiles/" because it is already running in the root directory of the project, therefore, if you want to put the uploaded file under the webroot \ upload directory, you need to change it to:/rpload /, you can --> <param-value>/UserFiles/</param-value> </init-param> <param-name> debug </param-name> <param-value> true </param-value> </init-param> <! -- Remember to change the value of FALSE to TRUE, whether to enable the upload function --> <param-name> enabled </param-name> <param-value> true </param-value> </init-param> <servlet -mapping> <servlet-name> Connector </servlet-name> <url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector </url- pattern> </servlet-mapping> <! -- Do not forget the code in the bold section above and below --> <servlet-mapping> <servlet-name> SimpleUploader </servlet-name> <url-pattern>/FCKeditor/editor/filemanager /upload/simpleuploader </url-pattern> </servlet-mapping> the optimization process is to embed components into the project, below we will compress and optimize the components and Remove useless files: delete all the files under the \ WebRoot \ FCKeditor \ editor \ filemanager \ browser \ default \ connectors directory, these are used to browse files. for jsp, servlet is used for processing, therefore, these files are redundant. All files in the \ WebRoot \ FCKeditor \ editor \ filemanager \ upload directory are deleted. The languages not required in the WebRoot \ FCKeditor \ editor \ lang directory are deleted, for example, keep Chinese [zh-cn.js] and English [EN. js] And fcklanguagemanager. delete unnecessary skin files in the \ WebRoot \ FCKeditor \ editor \ skins directory of js files. There are three skin types, which can be used to delete JSP pages as needed.★First, add the label statement in the header of the test. jsp page [directory adjustment is not required, it is feasible ]:★Then add the call statement at the corresponding position on the page. For the FCK tag, you can also add many attributes. Of course, you can also do not add them. Pay attention to the bold area below, I used two common attributes below, one being height adjustment and the other being component style. This is FCKeditor demo!★The receiving parameters can be written to the other 1. fckconfig. js configuration file. The file can be opened in the log book. After modification, the file will be saved as UTF-8 encoding format. Find: FCKConfig. TabSpaces = 0; change to FCKConfig. TabSpaces = 1; that is, you can use the Tab key in the editor. 2. If your editor is still used at the front-end of the website, for example, for message book or diary reply, you have to consider security. Do not use the Default toolbar on the front-end, you can either customize the function or use the Basic defined by the system, that is, the Basic toolbar, and find: FCKConfig. toolbarSets ["Basic"] = [['bold ', 'italic', '-', 'orderedlist', 'unorderedlist', '-',/* 'link ', */'unlink', '', 'style', 'fontsize', 'textcolor', 'bgcolor', '-', 'smilil', 'specialchar ', 'replace ', 'preview']; this is the Basic that has been changed. Remove the image function and the Add link function, because the image and link and flash and image button adding functions allow the front-end page to directly access and upload files, fckedito R also supports the right-click function in the editing area. FCKConfig. contextMenu = ['generic',/* 'link', */'anchor ',/* 'image', */'flash', 'select', 'textarea ', 'checkbox', 'Radio ', 'textfield', 'hiddenfield',/* 'imagebutton', */'call', 'bulletedlist', 'numberedlist', 'tablecell ', 'table', 'form']; this also removes the "link, image, FLASH, image button" function of the right mouse button. 3. Find FCKConfig. fontNames = 'arial; Comic Sans MS; Courier New; Tahoma; Times New Roman; Verdana; plus several common fonts: FCKConfig. fontNames = '; _ GB2312; Arial; Comic Sans MS; Courier New; Tahoma; Times New Roman; Verdana '; 4. Note that the uploaded file name cannot contain Chinese characters. Otherwise, the file cannot be displayed or downloaded through a link.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.