Java FCKeditor 2.6 + JSP configuration methods

Source: Internet
Author: User

From: http://www.sunchis.com/html/java/javaweb/2011/0318/270.html

According to this article, it is very useful.

There are many articles on how to integrate FCKeditor for Java configurations with your own projects. However, many of them copy and verify the feasibility of the configuration based on the absence of tests. There are hundreds of errors. More importantly, the copied configurations are outdated FCKeditor for Java 2.3 configuration methods, or even earlier. Now the FCKeditor version is 2.6, and its package name is changed from Com. fredck. FCKeditor to net. FCKeditor.

I am also working on a project. It takes a little time to configure and integrate FCKeditor into the project. I have also sorted out the detailed configuration process, hoping to fill in the gaps in this area, and hope that you will not copy them and post a technical article, there must be a basis to ensure the quality of the article.

Compared with earlier versions 2.6, FCKeditor for Java 2.3 has made many changes, making it easier to configure FCKeditor. For example, when simpleuploaderservle is integrated into ororservlet, the Web. xml configuration is much simpler. Let's talk about the detailed configuration steps in the following example.

Download the FCKeditor package

1. Access ingress. This compressed package is a visual FCKeditor source code package that supports JSP, PHP, ASP, and other languages.

2. Access ingress. Release ). To avoid errors, it is best to use fckeditor-java-demo-2.6.war, because this demo can run normally, because we need to use several lib libraries in this demo package during configuration.

After the download: fckeditor_2.6.6.zip and FCKeditor-java-demo-2.6.war, decompress them with WinRAR.

Configure FCKeditor and integrate with the project

3. Create a new project under eclipse (or other ide), for example, fckeditortest, http: // localhost: 8080/fckeditortest.

Copy the FCKeditor folder in the decompressed fckeditor_2.6.6.zip file to the current project folder. The directory structure of my fckeditortest project is as follows:

4. Configure web. xml. The configuration file is as follows, which is all. Other configuration is not required. Because simpleuploaderservle is integrated into ororservlet, you do not need to configure file uploads and so on.

 
 
  1. <servlet> 
  2.    <servlet-name>Connector</servlet-name> 
  3.    <servlet-class> 
  4.     net.fckeditor.connector.ConnectorServlet 
  5.    </servlet-class> 
  6.    <load-on-startup>1</load-on-startup> 
  7. </servlet> 
  8.  
  9. <servlet-mapping> 
  10.    <servlet-name>Connector</servlet-name> 
  11.    <url-pattern> 
  12.     /fckeditor/editor/filemanager/connectors/* 
  13.    </url-pattern> 
  14. </servlet-mapping> 

5. Unzip the FCKeditor-java-demo-2.6.war, copy all jar packages under \ WEB-INF \ Lib \ to your project \ WEB-INF \ Lib. This step is very important. FCKeditor should use these jar files.

6. Create a directory under the src directoryFCKeditor. PropertiesWrite such a row into the resource file:

 
 
  1. connector.userActionImpl=net.fckeditor.requestcycle.impl.UserActionImpl

7. Test page index. jsp:

 
 
  1. <% @ Page contenttype = "text/html; charset = UTF-8" pageencoding = "UTF-8" %>
  2. <% @ Taglib uri = "http://java.fckeditor.net" prefix = "fck" %>
  3. <HTML>
  4. <Head>
  5. <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
  6. <Title> FCKeditor test </title>
  7. </Head>
  8. <Body style = "text-align: center;">
  9. <Div style = "text-align: center; width: 600pt">
  10. <H2> FCKeditor test </H2>
  11. <HR>
  12. <Form action = "showdata. jsp" method = "Post">
  13. <Fck: Editor InstanceName = "test" Height = "400pt">
  14. <JSP: attribute name = "value"> www.sunchis.com </jsp: attribute>
  15. </Fck: Editor>
  16. <Input type = "Submit" value = "Submit"/>
  17. <Input type = "reset" value = "reset"/>
  18. </Form>
  19. </Div>
  20. </Body>
  21. </Html>

8. showdata. jsp:

 
 
  1. <% @ Page contenttype = "text/html; charset = UTF-8" pageencoding = "UTF-8" %>
  2. <HTML>
  3. <Head>
  4. <Title> FCKeditor-display data </title>
  5. <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
  6. </Head>
  7. <%
  8. Request. setcharacterencoding ("UTF-8 ");
  9. String data = request. getparameter ("test ");
  10. %>
  11. <Body>
  12. <H1> FCKeditor-display data
  13. <HR/> <br/>
  14. <% = Data %>
  15. </Body>
  16. </Html>

9. Test.

10. slimming FCKeditor

① Delete all files or folders starting with "_" in the FCKeditor directory, such as "_ samples" and "_documentation.html;

② Delete all files except fckconfig. JS, fckpackage. xml fckstyles. XML, and fcktemplates. xml under the FCKeditor directory, and retain the Editor folder;

③ Delete all files except en. js and zh-cn.js under the FCKeditor/Editor/lang directory;

④ Delete the ORs ors folder under the FCKeditor \ editor \ filemanager directory;

11. Download the project test source code

Download the war file that I have packaged, execute "file"> "import" in eclipse, select the type of file to be imported as war, and then import it to the eclipse workspace.

Download link http://dl.dbank.com/c0pvrayl25

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.