Getting started with ckeditor3.6 in JSP

Source: Internet
Author: User

Ckeditor api chm help document http://download.csdn.net/detail/guoquanyou/3622884

The JSP page uses the Rich Text control ckeditor to submit form data

Use the Rich Text control ckeditor to customize the style on the JSP page

JSP uses ckeditor and ckfinder to implement Rich Text and upload Functions

1. Download ckeditor

1. directly, the latest version is 3.6: http://ckeditor.com/download

Ii. Install ckeditor

Decompress ckeditor_3.5.zip to get the ckeditor folder. Copy the entire ckeditor folder to the root directory of the project, that is, under webroot.

3. Verify that ckeditor is successfully installed.

Deploy and run the project. Visit: http: // localhost/project name/ckeditor/_ samples/index.html.

Then"Ckeditor samples list"The ckeditor has been installed successfully.

4. Apply ckeditor

1. Import JS files

<SCRIPT type = "text/JavaScript" src = "<% = request. getcontextpath () %>/ckeditor. js"> </SCRIPT>

2. Create and use ckeditor

<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "GBK" %> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"> <HTML> 

Note:

1) textarea property value name = "content": the name can be defined at will, but it must be consistent with the followingCkeditor. Replace ('content ');Match

2)Ckeditor. Replace ('content ');Is the most basic method, indicating the editor instance created using ckeditor's javascript API,

ReplaceTextarea.

To add some attribute settings for ckeditor, the attributes must be written in braces,

Above {toolbar: 'full', skin: 'kama '}

5. Get the data in the editor

When submitting a form, you must determine whether the content in the editor is empty. In this case, you can use the javascript API of ckeditor:

Ckeditor. Instances. content. getdata ()

Function Test () {var editor_data = ckeditor. Instances. content. getdata (); If (editor_data = NULL | editor_data = "") {alert ("please fill in the content! "); Return false ;}}

Note: If you place a bunch of spaces in the editor, the content is not empty, because the editor will convert all spaces you typed into & nbsp;

Now, the ckediotr editor can be displayed and used on the page.

NOTE: If struts2 and other frameworks are used in your project, you can also obtain the content in the editor based on the textarea attribute name = "content". It is best to use blob for storage.

 

 

 

 

 

 

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.