Getting Started tutorial using CKEditor3.6 in JSP __jsp

Source: Internet
Author: User

ckeditor API CHM Help documentation http://download.csdn.net/detail/guoquanyou/3622884

JSP pages submit form data using Rich Text control CKEditor

JSP pages use Rich Text controls CKEditor custom styles

JSP uses CKEditor and Ckfinder to implement rich text and upload functions


First, download CKEditor

1. Direct download address, current latest version for 3.6:http://ckeditor.com/download

Second, install CKEditor

Unzip Ckeditor_3.5.zip, get CKEditor folder, copy ckeditor entire folder to the root of project project, that is, under Webroot

Third, verify the CKEditor is installed successfully

Deployment Run project, Access: http://localhost/project name/ckeditor/_samples/index.html

You can get a demo page for the ckeditor Samples List to show that CKEditor has been installed successfully

iv. Application of CKEditor

1. Import JS file

<script type= "Text/javascript" src= "<%=request.getcontextpath ()%>/ckeditor/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" >



Description

1 textarea attribute value name= "Content": the name can be defined arbitrarily, but must be with the following ckeditor.replace (' content '); The

2) ckeditor.replace (' content '); is the most basic notation, which represents an instance of an editor created using the CKEditor JavaScript API.

Replace the textareaabove.

To add some property settings for CKEditor, its properties must be written in the {} curly braces.

As above {toolbar: ' Full ', skin: ' Kama '}

v. Get the data in the editor

Sometimes when submitting a form, you need to determine whether the content in the editor is empty, and you can use the CKEditor JavaScript API:

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 play a bunch of blanks in the editor, the content is not empty because the editor will convert the spaces you have typed into &nbsp;

At this point, the CKEDIOTR Editor can be displayed and used on the page.

Supplemental NOTE: If you use STRUTS2 framework in your project, you can also get the contents of the editor based on the TEXTAREA properties name= above, preferably using a 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.