FCKeditor for JSP (Common settings and Chinese garbled characters)

Source: Internet
Author: User

Reproduced in: http://panjiangchuan.javaeye.com/blog/524921

 

Configure FCKeditor in the configuration file
1. directly modify the fckconfig. JS File
2. In the custom configuration file, the custom items will overwrite the default settings in the fckconfig. js file.
(1): Create a configuration file, which is a common JS file]
For example, create a myconfig. js file in the root directory of the project.
Content:
Fckconfig. autodetectlanguage = true;
Fckconfig. defaultlanguage = 'zh-cn ';
......
(2): Read the configuration file. [due to the uncertainty of the release project, the custom file is generally placed in the FCKeditor folder. fckconfig. editorpath represents the FCKeditor folder]
1): Modify fckconfig. customconfigurationspath = fckconfig. editorpath + 'myconfig. js' in the fckconfig. js file ';
2): Read the configuration file when calling FCKeditor and create the FCKeditor object ofckeditor (recommended for a single editing domain)
Ofckeditor. config ["customconfigurationspath"] = fckconfig. editorpath + "myconfig. js ";
Common configurations to be modified:
(1): Add common Chinese fonts: Modify or customize the fontnames attribute of the configuration file
Example: fckconfig. fontnames = '; _ gb2312;; Times New Roman; arial ';
(2): Set the toolbar: Modify or customize the toolbarsets attribute of the configuration file.
For example, fckconfig. toolbarsets ["Basic"] = [
['Bold ', 'italic', '-', 'orderedlist', 'unorderedlist', '-', 'link', 'unlink ','-', 'about']
];
Note: Basic: the name of the toolbar (used for calling). The word inside the single quotation mark represents a menu item-represents a separator/represents a line break [Refer to toolbarsets in fckconfig. js to set the toolbar]
(3): Modify the line feed behavior of "Carriage Return" and "Shift + carriage return": Modify or customize the fontnames attribute of the configuration file.
Example: fckconfig. entermode = 'br ';
Fckconfig. shiftentermode = 'P ';
Note: entermode: Carriage Return behavior shiftentermode: Shift + carriage return behavior [their values can only be one of P Div br]
(4): Modify the editing area Style File: Modify or customize the editorareacss attribute of the configuration file.
Example: fckconfig. editorareacss = fckconfig. basepath + 'css/fck_editorarea.css ';
Note: fckconfig. basepath refers to the FCKeditor/Editor folder.
(5): Configure emojis: Modify or customize the smileypath smileyimages smileycolumns smiley1_wwidth smiley1_wheight attribute of the configuration file.
Example: fckconfig. smileypath = fckconfig. basepath + 'images/smiley/MSN /';
Fckconfig. smileyimages = require 'regular_smile.gif '];
Fckconfig. smileycolumns = 8;
Fckconfig. smiley+wwidth = 320;
Fckconfig. smiley1_wheight = 210;
Note: smileypath: Specifies the folder where the emoticon is located. smileyimages specifies the emoticon image name. smileycolumns specifies the number of emotices displayed on each line. smiley1_wwidth smiley1_wheight specifies the width and height of the emoti. Modify the FCKeditor/Editor/dialog/fck_smiley.html file to comment out the dialog. setautosize (true); rows to display the emoticon list according to the specified width and height. Modify <body style = "overflow: hidden"> to <body style = "overflow: auto "> displays the scroll bar in the emoticons list.
Note: The basepath of the JSP page refers to the path of FCKeditor. JS, And the basepath of the configuration file refers to the editorpath of the configuration file in the FCKeditor/Editor folder.
File Upload control:
(1): file type control (divided into four types: file image Flash Media) [the two configurations must be synchronized]
1) configure the custom FCKeditor configuration file (the client configuration media has no client configuration)
Example: fckconfig. linkuploadallowedextensions = ".
(7z | AIFF | ASF | Avi | BMP | CSV | Doc | FLA | FLV | GIF | GZ | gzip | JPEG | JPG | mid | mov | MP3 | MP4 | MCM | MPEG | MPG | ODS | ODT | PDF | PNG | PPT | pxd | QT | Ram | RAR | RM | RMI | rmvb | RTF | SDC | sitd | SWF | SXC | Sxw | tar | tgz | TIF | tiff | TXT | ASD | WAV | WMA | WMV | XLS | XML | zip) $ ";
Fckconfig. imageuploadallowedextensions = ". (JPG | GIF | JPEG | PNG | BMP) $ ";
Fckconfig. flashuploadallowedextensions = ". (SwF | FLV) $ ";
2) configure the FCKeditor. properties resource file (server-side configuration) and add the following to the resource file:
Example: Connector. resourcetype. file. Extensions. Allowed =
7z | AIFF | ASF | Avi | BMP | CSV | Doc | FLA | FLV | GIF | GZ | gzip | JPEG | JPG | mid | mov | MP3 | MP4 | MCM | MPEG | MPG | ODS | ODT | PDF | PNG | PPT | pxd | QT | Ram | RAR | RM | RMI | rmvb | RTF | SDC | sitd | SWF | SXC | Sxw | tar | tgz | TIF | tiff | TXT | ASD | WAV | WMA | WMV | XLS | XML | zip
Connector. resourcetype. image. Extensions. Allowed = BMP | GIF | JPEG | JPG | PNG
Connector. resourcetype. Flash. Extensions. Allowed = SWF | fla
Connector. resourcetype. media. extensions. allowed = AIFF | ASF | Avi | BMP | FLA | FLV | GIF | JPEG | JPG | mid | mov | MP3 | MP4 | MCM | MPEG | MPG | PNG | QT | Ram | rm | RMI | rmvb | SWF | TIF | tiff | WAV | WMA | WMV
(2) File Size Control: Modify the dispatcher. Java file in the same way.
Chinese garbled solution:
(1): the latest fckeditor.java-2.5.bin.zip file will not contain garbled characters when uploading a Chinese file name.
(2) garbled characters occur when creating a Chinese directory: Modify the dispatcher. Class file under the net. FCKeditor. connector package.
1) download the fckeditor-java-2.5-src.zip source file.
2): Create net in your project directory. FCKeditor. connector package, copy fckeditor-java-2.5/Java-core/src/main/Java/NET/FCKeditor/connector/dispatcher. java file to this package. [Note: You must copy 6 jar files to the lib directory before editing the file]
3): edit the file. Find string newfoldernamestr = request. getparameter ("newfoldername") in the doget member method ");
Logger. debug ("parameter newfoldername :{}", newfoldernamestr );
Changed:
String newfoldernamestr = request. getparameter ("newfoldername ");
String temp = new string (newfoldernamestr. getbytes ("iso8859-1"), "UTF-8 ");
Newfoldernamestr = temp;
Logger. debug ("parameter newfoldername :{}", newfoldernamestr );
4): unzip the fckeditor-java-core-2.5.jar file, deploy your project, find your compiled Dispatcher in the classes folder after deployment. the class file replaces the net. FCKeditor. dispatcher in the connector folder. class, and re-package the file.
5): replace the original file with the changed fckeditor-java-core-2.5.jar file and redeploy.
(3): images that reference Chinese names cannot be displayed normally:
1): Modify the server configuration. [This is not recommended because garbled characters may occur in the parameters passed by get. For example, garbled characters may occur again when a Chinese folder is created.]: Modify Tomcat 6.0/CONF/server. configuration of the port corresponding to the server in the XML file
For example, if my tomcat port is 8080, the configuration in this section is changed:
<Connector Port = "8080" protocol = "HTTP/1.1"
Connectiontimeout = "20000"
Redirectport = "8443"
Uriencoding = "UTF-8"/>
2): Modify the name of the uploaded file [change the name to the current time (you can also use UUID to construct the name)] avoid Chinese: Modify the dispatcher. Java file again.
Find: String filename = filenameutils. getname (uplfile. getname () in dopost ());
Logger. debug ("parameter newfile :{}", filename );
To:
String filename = filenameutils. getname (uplfile. getname ());
String suffix = filename. substring (filename. lastindexof ("."));
Calendar CAD = calendar. getinstance ();
Filename = string. valueof (CAD. get (calendar. year) + String. valueof (CAD. get (calendar. month) + String. valueof (CAD. get (calendar. day_of_month) + String. valueof (CAD. get (calendar. hour_of_day) + String. valueof (CAD. get (calendar. minute) + String. valueof (CAD. get (calendar. second ));
Filename = filename + suffix;
Logger. debug ("parameter newfile :{}", filename );
3): Compile and package the same as above.

 

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.