富文本编辑ckeditor.js的使用

使用ckeditor.js编辑副本,生成静态页面

前端代码:

 

注:使用editor.getData()获得富文本中的内容,图片可以使用复制粘贴放入文本框

富文本编辑ckeditor.js的使用_第1张图片

后台java代码:

@RequestMapping("uploadHtml")
	public @ResponseBody Map uploadHtml(String html, HttpServletRequest request) {
		
		StringBuilder stringHtml = new StringBuilder();
		
		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		}
		
		//输入HTML文件内容
		stringHtml.append("");
		stringHtml.append("");
		stringHtml.append("测试报告文档");	
		stringHtml.append("");
		stringHtml.append("");
		stringHtml.append("
hello
"); stringHtml.append(""); String sb = null; if (Common.isEmpty(html)) { StringBuffer sbuffer=new StringBuffer(); try { BufferedReader br=request.getReader(); char[] buffer=new char[1024*1024]; int len; while((len=br.read(buffer))!=-1) { sbuffer.append(buffer,0,len); } sb = URLDecoder.decode(String.valueOf(sbuffer), "utf-8"); sb = String.valueOf(stringHtml).replace("hello", sb.split("html=")[1].replace(" hm = new HashMap(); try { File detail = new File("C:/uploadDoc/detail.html"); FileOutputStream fos = new FileOutputStream (detail); OutputStreamWriter bw = new OutputStreamWriter(fos, "UTF-8"); bw.write(sb); bw.close(); hm.put("flag", "SUCCESS:文档上传成功"); } catch (Exception e) { e.printStackTrace(); hm.put("flag", "ERROR:文档上传失败"); } return hm; }

使用request.getReader()获取超过上传要求的字节数

你可能感兴趣的:(springboot)