Layui Rich Text Editor is quite convenient to use, but the disadvantage is that it does not provide an interface for image upload, and you need to write the upload interface by yourself. The returned data type must meet the requirements of the Layui Rich Text Editor image upload plug-in. Otherwise, the image can be uploaded successfully, but it cannot be echoed. It took a long time to find that the data structure returned did not meet the requirements of Layui, and it was solved after modification. Now post the code to share. The code for bold fonts returns the data structure
@ResponseBody @RequestMapping(value = "fillupf", method = ) public String fillupf(@RequestParam("file") MultipartFile[] files) { try { String[] courseware = new String[]; int index = 0; for (MultipartFile file : files) { boolean isLegal = false; for (String type : ALLOW_FILE_TYPE) { if (((), type)) { isLegal = true; break; } } // Encapsulate the Result object and place the file's byte array into the result objectPicUploadResult fileUploadResult = new PicUploadResult(); // state(isLegal ? 0 : 1); // New path to the fileString filePath = getFilePath(()); if (()) { ("Pic file upload .[{}] to [{}] .", (), filePath); } // The absolute reference address for the generated imageString picUrl = ((filePath, propertieService.REPOSITORY_PATH), "\\", "/"); (propertieService.IMAGE_BASE_URL + picUrl); File newFile = new File(filePath); // Write files to disk(newFile); // state(isLegal ? 0 : 1); if (!isLegal) { // Illegal, delete the file on the disk(); } courseware[index++] = (); } String fillUrls=(courseware, ","); Map<String,Object> map = new HashMap<String,Object>(); Map<String,Object> map2 = new HashMap<String,Object>(); ("code",0);//0 means success, 1 fails ("msg","Uploaded successfully");// Prompt message ("data",map2); ("src",fillUrls);//Picture url ("title","Pictures are missing");//The image name will be displayed in the input box JSONObject jsonObject = (map); String result = (); return result; } catch(Exception e) { } return null; }
The above article solves the problem that the upload of layui rich text editor cannot be reprinted is all the content I have shared with you. I hope you can give you a reference and I hope you can support me more.