CKEditor使用
来源:互联网 发布:考研辅导班 知乎 编辑:程序博客网 时间:2024/06/06 01:09
1.实例已存在报错
if(CKEDITOR.instances.contenttexts){addCkeditor("contenttexts");}else{CKEDITOR.replace('contenttexts');} function addCkeditor(id){ var editor2 = CKEDITOR.instances[id]; if(editor2) editor2.destroy(true);//销毁编辑器 content2,然后新增一个 editor = CKEDITOR.replace(id); }
2.图片上传
在 config.js 里面 加上:
config.image_previewText = ' ';config.filebrowserUploadUrl = "admin/system/upload";var pathName = window.document.location.pathname;var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1); config.filebrowserImageUploadUrl = projectName+'/system/upload.do'; //固定路径
Action地址固定
@Controller@RequestMapping("/system")public class UpLoadImgAction {public static final Long maxFileSize = XX;public static final Long maxVideoSize = XX;@RequestMapping("/upload")public void uploadImg(HttpServletRequest request,HttpServletResponse response,@RequestParam("upload") MultipartFile[] File) throws IOException{String realpath = request.getSession().getServletContext().getRealPath("/");//服务存图片的文件夹地址if (File != null && lFile.length > 0) {if (!File[0].isEmpty()) {long length = File[0].getSize();if (length > maxFileSize) {String jsht = "<script>alert('上传的图片过大(超700k),提交失败');</script>";PublicSubfun.writehtml(jsht, response);}String[] type = File[0].getContentType().split("/");File f = new File(realpath + "/" + System.currentTimeMillis()+ "." + type[1]);FileUtils.copyInputStreamToFile(picurlFile[0].getInputStream(),f); String url = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/服务存图片的文件夹地址/" + f.getName(); StringBuffer sb = new StringBuffer(); sb.append("<script type=\"text/javascript\">"); sb.append("window.parent.CKEDITOR.tools.callFunction("+ CKEditorFuncNum + ",'" +url + "','')"); sb.append("</script>"); PublicSubfun.writehtml(sb.toString(),response);} }}}
</pre><pre>
0 0
- CKeditor使用
- ckeditor使用
- CkEditor使用
- CKEditor使用
- ckeditor使用
- ckeditor使用
- CKEditor 使用
- CKEditor使用
- ckeditor使用
- 使用CKEditor
- 【CKEditor 】CKEditor 使用与简单配置简介
- 【CKEditor 】CKEditor 使用与简单配置简介
- CKeditor配置使用(转)
- CKEditor使用配置
- CKEditor配置使用
- ckeditor的使用
- Struts2使用ckeditor
- Sturts中使用CKEditor
- 循环链表解决约瑟夫环问题
- 解决GET请求时中文乱码的问题
- CodeForces 489D Unbearable Controversy of Being
- 推荐!国外程序员整理的 PHP 资源大全
- JNI小结
- CKEditor使用
- jasper.JasperException:
- 随笔-Undefined symbols for architecture i386 _deflate referenced from || -fno-objc-arc
- 每位设计师都应该拥有的50个CSS代码片段
- php array_multisort 二维数组排序
- Java小数四舍五入与保留位(三)
- String 和 StringBuffer
- 性能优化
- python模块介绍-gevent介绍:基于协程的网络库