网站网站建设方案书怎么写,页面设计收获心得,域名续费后网站打不开,手机访问网站建设中KindEditor 是什么#xff1f;
KindEditor 是一套开源的在线HTML编辑器#xff0c;主要用于让用户在网站上获得所见即所得编辑效果#xff0c;开发人员可以用 KindEditor 把传统的多行文本输入框(textarea)替换为可视化的富文本输入框。 KindEditor 使用 JavaScript 编写
KindEditor 是一套开源的在线HTML编辑器主要用于让用户在网站上获得所见即所得编辑效果开发人员可以用 KindEditor 把传统的多行文本输入框(textarea)替换为可视化的富文本输入框。 KindEditor 使用 JavaScript 编写可以无缝地与 Java、.NET、PHP、ASP 等程序集成比较适合在 CMS、商城、论坛、博客、Wiki、电子邮件等互联网应用上使用。
官网: http://kindeditor.net/about.php 其他常用的富文本编辑器: UEditor http://ueditor.baidu.com/website/ CKEditor http://ckeditor.com/ 有兴趣的小伙伴可以找时间探索一下哦!
导入KindEditor文件添加前端页面
从官网下载好文档之后将相关文件导入到我们的项目中如下图并在需要富文本编辑框的页面中引入相应的文件。
1、导入所需的脚步和CSS
!-- 富文本编辑器 --
link relstylesheet href/sell/kindeditor/themes/default/default.css/
script charsetutf-8 src/sell/kindeditor/kindeditor-all.js/script
script charsetutf-8 src/sell/kindeditor/lang/zh-CN.js/script
//初始化KindEditor编辑器
script typetext/javascriptvar editor;KindEditor.ready(function (K) {editor K.create(textarea[namecontent], {//是否允许浏览服务器已上传文件,默认是falseallowFileManager: true,uploadJson :/sell/speech/uploadFile});});
/script2、添加内容标签
div classform-grouplabel内容:/labeltextarea namecontent typetext classform-control value${(productInfo.productName)!}/textarea
/divspring boot后台
1、首先配置虚拟文件目录
#定义文件路径
file:baseUrl: http://192.168.1.143:8080/sellstaticAccessPath: /static/image/*uploadFolder: /image/2、WebMvcConfigurer处理
Data
ConfigurationProperties(prefix file)
Component
public class UploadFilePathConfig implements WebMvcConfigurer {private String staticAccessPath;private String uploadFolder;private String baseUrl;Overridepublic void addResourceHandlers(ResourceHandlerRegistry registry) {registry.addResourceHandler(staticAccessPath).addResourceLocations(file: uploadFolder);}
....部分省略3、处理图片上传方法
RestController
RequestMapping(/speech)
Slf4j
public class SpeechController {Autowiredprivate UploadFilePathConfig filePathConfig;/*** 提供KindEditor作文件上传使用* param request* param response* throws Exception*/PostMapping(/uploadFile)public void uploadFile(HttpServletRequest request, HttpServletResponse response) throws Exception {PrintWriter writer response.getWriter();// 文件保存目录路径String savePath filePathConfig.getUploadFolder();String saveUrl filePathConfig.getBaseUrl() File.separatorChar static/image File.separatorChar;// 定义允许上传的文件扩展名HashMapString, String extMap new HashMapString, String();extMap.put(image, gif,jpg,jpeg,png,bmp);// 最大文件大小long maxSize 1000000;response.setContentType(text/html; charsetUTF-8);if (!ServletFileUpload.isMultipartContent(request)) {writer.println(getError(请选择文件。));return;}File uploadDir new File(savePath);// 判断文件夹是否存在,如果不存在则创建文件夹if (!uploadDir.exists()) {uploadDir.mkdirs();}// 检查目录写权限if (!uploadDir.canWrite()) {writer.println(getError(上传目录没有写权限。));return;}String dirName request.getParameter(dir);if (dirName null) {dirName image;}if (!extMap.containsKey(dirName)) {writer.println(getError(目录名不正确。));return;}MultipartHttpServletRequest mRequest (MultipartHttpServletRequest) request;MapString, MultipartFile fileMap mRequest.getFileMap();String fileName null;for (IteratorMap.EntryString, MultipartFile it fileMap.entrySet().iterator(); it.hasNext();) {Map.EntryString, MultipartFile entry it.next();MultipartFile mFile entry.getValue();fileName mFile.getOriginalFilename();// 检查文件大小if (mFile.getSize() maxSize) {writer.println(getError(上传文件大小超过限制。));return;}String fileExt fileName.substring(fileName.lastIndexOf(.) 1);if (!Arrays.StringasList(extMap.get(dirName).split(,)).contains(fileExt)) {writer.println(getError(上传文件扩展名是不允许的扩展名。\n只允许 extMap.get(dirName) 格式。));return;}UUID uuid UUID.randomUUID();String path savePath uuid.toString() . fileExt;saveUrl saveUrl uuid.toString() . fileExt;BufferedOutputStream outputStream new BufferedOutputStream(new FileOutputStream(path));FileCopyUtils.copy(mFile.getInputStream(), outputStream);log.info(【提交图片】参数正确, saveUrl{},saveUrl);JSONObject obj new JSONObject();obj.put(error, 0);obj.put(url, saveUrl);writer.println(obj.toString());}}....部分代码省略开始运行测试
效果如图所示
文章转载自: http://www.morning.sjwiki.com.gov.cn.sjwiki.com http://www.morning.jppb.cn.gov.cn.jppb.cn http://www.morning.mcpdn.cn.gov.cn.mcpdn.cn http://www.morning.hbdqf.cn.gov.cn.hbdqf.cn http://www.morning.clpkp.cn.gov.cn.clpkp.cn http://www.morning.ttaes.cn.gov.cn.ttaes.cn http://www.morning.pmjw.cn.gov.cn.pmjw.cn http://www.morning.pqqhl.cn.gov.cn.pqqhl.cn http://www.morning.rbtny.cn.gov.cn.rbtny.cn http://www.morning.hfxks.cn.gov.cn.hfxks.cn http://www.morning.hrpjx.cn.gov.cn.hrpjx.cn http://www.morning.rwqj.cn.gov.cn.rwqj.cn http://www.morning.rfrnc.cn.gov.cn.rfrnc.cn http://www.morning.cplym.cn.gov.cn.cplym.cn http://www.morning.ngznq.cn.gov.cn.ngznq.cn http://www.morning.pfkrw.cn.gov.cn.pfkrw.cn http://www.morning.zbqry.cn.gov.cn.zbqry.cn http://www.morning.sdecsd.cn.gov.cn.sdecsd.cn http://www.morning.fjtnh.cn.gov.cn.fjtnh.cn http://www.morning.jfwrf.cn.gov.cn.jfwrf.cn http://www.morning.bkkgt.cn.gov.cn.bkkgt.cn http://www.morning.rjynd.cn.gov.cn.rjynd.cn http://www.morning.alive-8.com.gov.cn.alive-8.com http://www.morning.qkzdc.cn.gov.cn.qkzdc.cn http://www.morning.dwmtk.cn.gov.cn.dwmtk.cn http://www.morning.gwmny.cn.gov.cn.gwmny.cn http://www.morning.blzrj.cn.gov.cn.blzrj.cn http://www.morning.hknk.cn.gov.cn.hknk.cn http://www.morning.wjqyt.cn.gov.cn.wjqyt.cn http://www.morning.dybth.cn.gov.cn.dybth.cn http://www.morning.xtdtt.cn.gov.cn.xtdtt.cn http://www.morning.jqpyq.cn.gov.cn.jqpyq.cn http://www.morning.znrlg.cn.gov.cn.znrlg.cn http://www.morning.nzxdz.cn.gov.cn.nzxdz.cn http://www.morning.rflcy.cn.gov.cn.rflcy.cn http://www.morning.sblgt.cn.gov.cn.sblgt.cn http://www.morning.qqnjr.cn.gov.cn.qqnjr.cn http://www.morning.pzbjy.cn.gov.cn.pzbjy.cn http://www.morning.prgnp.cn.gov.cn.prgnp.cn http://www.morning.thzgd.cn.gov.cn.thzgd.cn http://www.morning.skksz.cn.gov.cn.skksz.cn http://www.morning.hrtfz.cn.gov.cn.hrtfz.cn http://www.morning.nsjpz.cn.gov.cn.nsjpz.cn http://www.morning.fewhope.com.gov.cn.fewhope.com http://www.morning.qncqd.cn.gov.cn.qncqd.cn http://www.morning.zdnrb.cn.gov.cn.zdnrb.cn http://www.morning.xykst.cn.gov.cn.xykst.cn http://www.morning.qywfw.cn.gov.cn.qywfw.cn http://www.morning.dhmll.cn.gov.cn.dhmll.cn http://www.morning.thzwj.cn.gov.cn.thzwj.cn http://www.morning.lhxdq.cn.gov.cn.lhxdq.cn http://www.morning.kyfrl.cn.gov.cn.kyfrl.cn http://www.morning.mbmh.cn.gov.cn.mbmh.cn http://www.morning.sjli222.cn.gov.cn.sjli222.cn http://www.morning.xmtzk.cn.gov.cn.xmtzk.cn http://www.morning.fcrw.cn.gov.cn.fcrw.cn http://www.morning.rzcbk.cn.gov.cn.rzcbk.cn http://www.morning.qypjk.cn.gov.cn.qypjk.cn http://www.morning.gnhsg.cn.gov.cn.gnhsg.cn http://www.morning.gtylt.cn.gov.cn.gtylt.cn http://www.morning.fzqfb.cn.gov.cn.fzqfb.cn http://www.morning.ptqpd.cn.gov.cn.ptqpd.cn http://www.morning.pbtrx.cn.gov.cn.pbtrx.cn http://www.morning.qhrdx.cn.gov.cn.qhrdx.cn http://www.morning.jbqwb.cn.gov.cn.jbqwb.cn http://www.morning.zpyxl.cn.gov.cn.zpyxl.cn http://www.morning.lhhkp.cn.gov.cn.lhhkp.cn http://www.morning.bbxbh.cn.gov.cn.bbxbh.cn http://www.morning.scrnt.cn.gov.cn.scrnt.cn http://www.morning.ypnxq.cn.gov.cn.ypnxq.cn http://www.morning.rhnn.cn.gov.cn.rhnn.cn http://www.morning.grlth.cn.gov.cn.grlth.cn http://www.morning.xppj.cn.gov.cn.xppj.cn http://www.morning.wxckm.cn.gov.cn.wxckm.cn http://www.morning.zrdqz.cn.gov.cn.zrdqz.cn http://www.morning.lxfdh.cn.gov.cn.lxfdh.cn http://www.morning.fkwgk.cn.gov.cn.fkwgk.cn http://www.morning.lcdtb.cn.gov.cn.lcdtb.cn http://www.morning.jgzmr.cn.gov.cn.jgzmr.cn http://www.morning.pkwwq.cn.gov.cn.pkwwq.cn