当使用SpringMVC并且同时使用ckeditor作为文本域插件使用的时候,会遇到textarea中的值无法被SpringMVC自动封装。这时候需要使用隐藏域将textarea中的值copy到隐藏域中
jsp:
<textarea id="editor1"></textarea>
<input type="hidden" name="detailed" id="valueNode">
js:
var textareaNode = CKEDITOR.replace('editor1', {
"filebrowserUploadUrl" : "file_upload.do",
uiColor : '#19A094', //工具栏颜色色
enterMode : CKEDITOR.ENTER_BR //换行直接加br
});
$("#valueNode").val(textareaNode.getData());
当页面中的textarea需要回显的时候,可以使用
var textareaValue = CKEDITOR.replace('editor1');
textareaValue.setData();
总结:
ckeditor中为获取和设置textarea中的值提供了两个api
obj.getData();
obj.setData();
当使用别人的插件的时候,某些功能不能正常实现,一般插件会提供相应的解决方案。可以浏览官网和google或者百度

本文介绍如何解决在SpringMVC项目中使用ckeditor时出现的textarea值无法自动封装的问题,并提供了解决方案,包括使用隐藏域进行值传递及如何在页面中正确回显文本。
500

被折叠的 条评论
为什么被折叠?



