Configure FCKeditor 2.6.3 and FCKeditor. Java 2.4 in JSP

Source: Internet
Author: User

1. FCKeditor Introduction
FCKeditor, an open-source HTML text editor, allows web programs to have powerful editing functions such as MS Word. FCKeditor supports the following popular browsers:

2. preparations:

Environment: winddows XP, tomcat6.0, and jdk1.6
Download:
1): fckeditor_2.6.3b.zip
Address: http://nchc.dl.sourceforge.net/sourceforge/fckeditor/FCKeditor_2.6.3b.zip
2): fckeditor-java-2.4-bin.zip (Java support package) Address http://nchc.dl.sourceforge.net/sourceforge/fckeditor/fckeditor-java-2.4-bin.zip
3366slf4j-1.5.2.zip address: http://slf4j.org/dist/slf4j-1.5.2.zip

3. installation:

1. Decompress fckeditor_2.6.3b.zip and copy the entire decompressed FCKeditor folder to the project directory webroot.
2)decompress fckeditor-java-2.4-bin.zip, extract 4 jar packages in the extract files of the fckeditor-java-2.4-bin, fckeditor-java-core-2.4.jar, commons-fileupload-1.2.1.jar, commons-io-1.3.2.jar, slf4j-api-1.5.2.jar,
3366extract slf4j-1.5.2.zip, just extract the slf4j-jdk14-1.5.2.jar package
4) The 5 packages extracted in steps 2 and 3 are all imported into the project directory WEB-INF/bin.
(
In the beginning, I only imported four packages intercepted in step 1. When Tomcat is started, the system prompts that the org class cannot be found. slf4j. impl. staticloggerbider: Go to the official documentation and go to the slf4j official website to get the latest version, but I don't know Org. slf4j. impl. which package is the staticloggerbider class? This is my dumbest. I will import all the packages and find them slowly (Khan ......), Then, remove the extra package (right-click the project → properties → Java build path → libraries to remove the extra package) and restart the package. Now, no error of the class not found is reported, but there are hundreds of Java. lang. stackoverflowerror (sweating ......), After checking for N for a long time, there was no result. Then, in the lib directory of myeclipse, I found a lot of packages that were just removed. Then I right-clicked them and deleted them, and restarted them. Hey, OK.
)

4. Configuration

1) create a file FCKeditor. properties in the src/directory, and add the following content: Connector. useractionimpl = net. FCKeditor. requestcycle. impl. useractionimpl.
2) modify web. XML to support the upload function,
Add content:
<Servlet>
<Servlet-Name> connector </servlet-Name>
<Servlet-class>
Net. FCKeditor. connector. connectorservlet
</Servlet-class>
<Load-on-startup> 1 </load-on-startup>
</Servlet>
<Servlet-mapping>
<Servlet-Name> connector </servlet-Name>
<URL-pattern>
/FCKeditor/Editor/filemanager/connectors /*
</Url-pattern>
</Servlet-mapping>
5. Application
Create index. jsp and result. jsp files under the project directory webroot,
Index. jsp:
<% @ Page Language = "Java" import = "java. util. *" pageencoding = "UTF-8" %>
<% @ Taglib uri = "http://java.fckeditor.net" prefix = "fck" %>
<%
String Path = request. getcontextpath ();
String basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/";
%>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
<Head>
<Base href = "<% = basepath %>">
<Title> FCKeditor. java2.4 for fckeditor2.6.3beate text </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Meta http-equiv = "Pragma" content = "no-Cache">
<Meta http-equiv = "cache-control" content = "no-Cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "Description" content = "this is my page">
</Head>
<Body>
<Form action = "result. jsp" method = "Post">
<Fck: Editor InstanceName = "content">
<JSP: attribute name = "value">
Your content .....
</Jsp: attribute>
</Fck: Editor>
<Input type = "Submit" value = "Submit">
</Form>

</Body>
</Html>
Result. jsp
<% @ Page Language = "Java" import = "java. util. *" pageencoding = "UTF-8" %>
<%
String Path = request. getcontextpath ();
String basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/";
%>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
<Head>
<Base href = "<% = basepath %>">
<Title> my JSP 'result. jsp 'starting page </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Meta http-equiv = "Pragma" content = "no-Cache">
<Meta http-equiv = "cache-control" content = "no-Cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "Description" content = "this is my page">
</Head>
<Body>
<% = Request. getparameter ("content") %>
</Body>
</Html>

Enter http: // localhost: 8080/fcktest OK in the IE address!

6. Deficiencies

There is no perfect girl in the world (I don't know if you have found a perfect girl, if you are wrong, don't beat me). The same is true for fck.
1) enter Chinese characters in the text box and garbled characters will be obtained after submission.
Solution:
Transcode in result. jsp:
New String (request. getparameter ("content"). getbyte (iso-8859-1), "UTF-8 ")
In the test, "" is successful!
Or add
<%
Request. setcharacterencoding ("UTF-8 ");
%>
<Body>
<H1> FCKeditor-display data <HR/> <br/>
<% = Request. getparameter ("context") %>
</Body>
</Html>

2) garbled Chinese image names saved after uploading a Chinese name Image
Work und: Modify connectorservlet. Java (upload. setheaderencoding ("fckeditor-java-core-2.4.jar");) in the UTF-8 package to replace the fckeditor-java-core-2.4.jar package that was previously downloaded,
OK. The name of the uploaded Chinese image is displayed normally,

3) Click Browse server and select the newly uploaded Chinese image. The image cannot be displayed in the preview window.
Solution:
Modify the server. xml file under the tomcat installation directory config and add uriencoding = "UTF-8" to the <connector/> label ″.
OK. The Chinese image is displayed normally.

4) enable Flash upload
A. When uploading a Chinese file name in flash, sometimes the pop-up does not have the permission, or the file type is incorrect, sometimes the upload is normal.
B. When the English or digital flash is uploaded, the window remains in the waiting status. Close the window later and click the Browse server button to see that flash has been uploaded successfully.
C. Sometimes the preview window cannot be played if the upload is successful.
D. Sometimes the file name can be uploaded successfully regardless of the language used.
However, as long as you are using an English letter or a digital file name, you can upload the file 100%.

Therefore, it is estimated that this issue is caused by encoding.

5 ). Fckeditor2.6.2 File Upload is incompatible with Struts 2.
Solution:
Let struts2 process only *. Action requests. Modify the configuration file web. xml:
Configure the filter for struts2 to process all Web requests
<Filter-mapping>
<Filter-Name> struts2 </filter-Name>
<URL-pattern>/* </url-pattern>
</Filter-mapping>
Change to: process only. Action or. jsp requests
<Filter-mapping>
<Filter-Name> struts2 </filter-Name>
<URL-pattern> *. Action </url-pattern>
</Filter-mapping>
<Filter-mapping>
<Filter-Name> struts2 </filter-Name>
<URL-pattern> *. jsp </url-pattern>
</Filter-mapping>
Note: The above configuration file changes will cause the struts2 tag not to be displayed on the page.
The following configuration should be added to the web. xml file:
<Filter-mapping>
<Filter-Name> struts2 </filter-Name>
<URL-pattern>/struts/* </url-pattern>
</Filter-mapping>

Note: FCKeditor encoding is an old and difficult task. It is very difficult for him to really handle Chinese characters, for example, after a great deal of effort was made to upload and browse images with Chinese names, there was another problem with flash. These are all code errors.

7. Conclusion:

Fckeditor2.6.3 Beta has been greatly improved on the basis of 2.6.2. fckeidtor 2.6.3beta has been greatly simplified in terms of configuration, making it easier for users to get started. However, FCKeditor encoding is a tough problem, it is particularly outstanding in the file upload function. It is hoped that fck will be able to fix this bug in future versions.

Http://blog.waw8.com/tag/fckeditor-263%E5%9C%A8jsp%E4%B8%AD%E9%85%8D%E7%BD% AE

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.