ckEditor使用经验

第一步 下载ckeditor 进入官网https://ckeditor.com/ckeditor-4/download/点击Release notes选择4.8.0版本点击Download.Zip下载

第二步 加入ckeditor文件夹到项目下 引入

描述:

上面的js中description可以是id也可以是name
第三步 就是设置图片上传ckEditor使用经验_第1张图片ckeditor文件夹下的config.js中添加:
//设置预览页面为空
config.image_previewText=’ ';

//设置上传路径
config.filebrowserUploadUrl='/f/cms/util/uploadImage';

//设置高和宽
config.width=500;
config.height =380;

/**
* 富文本编辑器图片上传
* @param file
* @return
*/
@RequestMapping(value = “/uploadImage”, method = RequestMethod.POST)
public void uploadImage(@RequestParam(“upload”)MultipartFile[] file, HttpServletResponse response,HttpServletRequest request,HttpSession session) {
response.setCharacterEncoding(“UTF-8”);
PrintWriter out = null;
// CKEditor提交的很重要的一个参数 ,回调函数的序号
String callback = request.getParameter(“CKEditorFuncNum”);
try {
out = response.getWriter();
} catch (IOException e1) {
e1.printStackTrace();
}
UploadFileEntity fileInfo = null;
//上传目录地址
// String uploadDir = session.getServletContext().getRealPath("/") + “upload/”;
filePath = “D:\dpicmsUploadFile\imagesForAll\”;
下面的100就是去找的filePath
String uploadDir = UidUtil.getFilePath(100);
//如果目录不存在,自动创建文件夹
File dir = new File(uploadDir);
try {
List uploadFileEntityList = null;
try {
uploadFileEntityList = UidUtil.springUpload(request,100);
} catch (IOException e) {
e.printStackTrace();
}
if (null != uploadFileEntityList && uploadFileEntityList.size() > 0) {
boolean isSuccess = utilService.saveUploadFileList(uploadFileEntityList);
if (!isSuccess){
System.out.println(“上传成功”+uploadFileEntityList.get(0).getNewFileName());
}
}
// 返回"图像"选项卡并显示图片 request.getContextPath()为web项目名 4.8.0使用
out.println("

你可能感兴趣的:(学习经验)