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.