关于富文本框KindEditor的使用

本文介绍了如何使用富文本编辑器KindEditor,提供了官网和资源下载链接,详细讲解了前端后端的集成过程,特别是针对Linux环境下与JSP的兼容问题,以及动态配置编辑器功能的方法。内容包括上传图片、查看已上传文件、动态地图等功能,并展示了最终效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 首先献上官网地址和资源

   js,css等资源百度云链接:https://pan.baidu.com/s/1tbSeToJQ1BYsXNPKChX7Zg 密码:xry2

2.具体前端后端代码(html没有加入其他样式)

  引入上面的js和css

<textarea id="description" name="goodConte" style="width:80%" rows="20">${goods.goodConte}</textarea>
$(function(){
    KindEditor.ready(function(K) {
        window.editor = K.create('#description',{
            items : [
                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
                'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                'anchor', 'link', 'unlink', '|', 'about'
            ],
                allowImageUpload:true,//允许上传图片
                allowFileManager:true,
                allowPreviewEmoticons : true,
                uploadJson : '../WxGoods/imageUpload',//富文本框图片上传
                fileManagerJson : '../WxGoods/imageManage',//富文本框图片查看
                urlType : "domain",
                afterBlur: function(){this.sync();}//解决表单通过ajax请求提交造成的提交不到后台的问题
        });
    }); 
});
//富文本框图片上传
@ResponseBody
@RequestMapping(value = "/imageUpload",method = RequestMethod.POST)
public Map<String, Object> imageUpload(HttpServletRequest request,HttpServletResponse response,RedirectAttributes ra) throws Exception {
	ServletContext application = request.getSession().getServletContext();
    String Path = application.getRealPath("/");
    File uploadDir1 = new File(Path);
        
        String savePath  = uploadDir1.getParent()+ "/file/KindEditor/";
        
        //展示到富文本框上的链接
        String saveUrl = "/file/KindEditor/";
         
         // 定义允许上传的文件扩展名
         HashMap<String, String> extMap = new HashMap<String, String>();
         extMap.put("image", "gif,jpg,jpeg,png,bmp");
         extMap.put("flash", "swf,flv");
         extMap.put("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb");
         extMap.put("file", "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2");
 
         // 最大文件大小
         long maxSize = 1000000;
 
         response.setContentType("text/html; charset=UTF-8");
 
         if
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值