使用spring将图像url添加到ckeditor
Add image url to ckeditor using spring
我正在使用ckeditor上传数据库中的内容,一切都很顺利。我添加了config.filebrowserImageUploadUrl = 'uploadBlogFile'
(我的控制器操作),但当我上传图像时,图像url没有添加到图像窗口上的text_field。。。
**My config.js**
CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here.
// For complete reference see:
// http://docs.ckeditor.com/#!/api/CKEDITOR.config
// The toolbar groups arrangement, optimized for two toolbar rows.
config.toolbarGroups = [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },
{ name: 'links' },
{ name: 'insert' },
{ name: 'forms' },
{ name: 'tools' },
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'others' },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
{ name: 'styles' },
{ name: 'colors' },
{ name: 'about' }
];
// Remove some buttons provided by the standard plugins, which are
// not needed in the Standard(s) toolbar.
config.removeButtons = 'Underline,Subscript,Superscript,About';
// Set the most common block elements.
config.format_tags = 'p;h1;h2;h3;pre';
// Simplify the dialog windows.
config.removeDialogTabs = 'image:advanced;link:advanced';
config.filebrowserImageUploadUrl = 'uploadBlogFile';
};
-------------------------------------------------------------
**My controller**
@RequestMapping(value = "/member/uploadBlogFile", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> uploadBlogFile(HttpSession session,HttpServletResponse response,
@RequestParam MultipartFile upload) {
User user = (User) session.getAttribute("user");
String filePath = null;
String imageSource = null;
List<String> list = new ArrayList<String>();
Map<String, Object> jsonMap = new HashMap<String, Object>();
try {
if (!upload.isEmpty()) {
jsonMap.put("uploaded", 1);
jsonMap.put("fileName", upload.getOriginalFilename());
filePath = blogService.uloadBlogFile(user.getUserId(), upload);
}
if (filePath != null) {
imageSource = DbConstants.AMAZON_S3_URL + DbConstants.SUFFIX
+ filePath;
}
if (imageSource != null && !imageSource.trim().isEmpty()) {
list.add(imageSource);
jsonMap.put("url",imageSource);
}
list.add(filePath);
} catch (IOException e) {
e.printStackTrace();
} catch (FixitException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
return jsonMap;
}
我已经得到了这个问题的解决方案。这基本上是由于我的控制器上没有windowparent.CKEDITOR.tools.callFunction。
我的控制器
在控制器上添加以下字符串,并作为json响应返回。
字符串路径="windowparent.CKEDITOR.tools.callFunction("+CKEditorFuncNum+",''"+url+",''""+"+"''");";
相关文章:
- 向ckeditor中的多个元素添加内联样式
- 在运行时添加更多的ckeditor
- 如何在CKEditor中为图像添加ID
- CKEditor,初始化用insertElement添加的小部件
- 有没有一种方法可以在运行中添加CKEditor的按钮到链接插件
- 如何将 CSS 添加到 CKEDITOR
- 如何将占位符属性添加到 CKEditor 的实例
- 如何在 CKEditor 表的单元格属性中添加新属性
- 如何禁用 CKEditor 表行列添加处理程序
- 将代码片段插件添加到 Rails 应用程序中的 CKEditor
- ckeditor 4 jQuery Adapter, 如何添加自定义按钮.
- 无法从动态添加的 CKEditor 文本区域读取数据
- 如何添加 ckEditor 表插件
- 当我使用 ckeditor 工具栏时,它会添加 html 标签,而不是在显示时添加所需的效果
- 动态添加内容样式到 CKEditor 4 实例
- 在 Drupal 的 CKEditor 4 中添加要链接的属性
- 铬中的 CKEDITOR 在光标位置添加“?”标记,同时应用任何样式(粗体/斜体)而不选择
- 如何在 CKeditor 上传中向 POST 值添加字段
- CKEditor 4:如何从插件添加CSS样式表
- 如何使用 CKEditor 将新按钮添加到组中