JSP-08-use of third-party controls, jsp-08-third-party controls
Add Image
1) Check the request type
Boolean isMultpart = ServletFileUpload. isMultipartContent (requeset );
If (isMultpart) // when enctype = "multipart/form-data" and method = "post", this value is true
2) declared object
DiskFileItemFactory factory = new DiskFileItemFactory ();
ServletFileUpload upload = new ServletFileUpload (factory );
3) Conversion request object
List <FileItem> items = null;
Items. parseRequest (request );
4) Save the uploaded file
If (item. isFormField ){
File. fullFile = new File (item. getName );
File uploadFile = new File (realPath, fullFile. getName );
Item. write (uploadFile );
}
5) obtain common fields
If (item. isFormField ){
Fieldname = item. getFieldName ();
If (fieldname. equals ("title ")){
News. setTitle (item. getString ("UTF-8 "));
}
}
WYSIWYG
Http://ckeditor.com/download
<Script type = "text/javascript" src = "<% = request. getContextPath () %>/ckeditor. js"> </script>
3. Use CKEditor to edit content
Add class = "ckeditor" to the "content" textarea tag"
4. Submit the content edited by CKEditor
Note: The field type in the database is "CLOB" (oracle)
--------------------
1. The meaning of the CKEditor folder
_ Samples: stores the official Demo
Lang: stores multi-language files
Skins: Skin folder
2. You can configure ckeditor through the CKEditor. js file,
CKEDITOR. editorConfig = function ()
{
Config. language = 'zh-cn'; // configuration language
Config. uiColor = '# AADC6E ';
Config. width = 'auto ';
Config. skin = 'office2003 '; // skin: v2, kama, office2003
};