我已经成功实现tinymce编辑器并将内容保存到数据库中。保存后,我可以在同一编辑器中编辑内容。但我只想显示输出(不是编辑模式,没有滚动条)。我在谷歌搜索但没有任何正确的答案。有人不知道该怎么做吗?我使用以下代码进行编辑模式:
tinymce.init({
selector: 'textarea',
height: 500,
theme: 'modern',
plugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime media nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc'
],
toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
toolbar2: 'print preview media | forecolor backcolor emoticons | codesample',
image_advtab: true,
templates: [
{ title: 'Test template 1', content: 'Test 1' },
{ title: 'Test template 2', content: 'Test 2' }
],
content_css: [
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
'//www.tinymce.com/css/codepen.min.css'
]
});
最佳答案
我也使用 TinyMCE 和 Java spring MVC。 在我的 Java 类中:
String anyText = "<strong>abc</strong>";
model.addAttribute("anyText","myText");
在 JSP 中:
<span>${anyText}</span>
显示
abc
如果您这样做,它不会以粗体文本显示在 HTML 中。
<span><c:out value="${anyText}"/></span>
关于javascript - 如何使用tinymce显示输出(非编辑模式),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43883641/