springboot+ueditor+前后端分离

基于springboot与前后端分离使用Ueditor遇到的问题  慢慢来比较快,虚心学技术 前言:前后端分离的项目,需要使用ueditor富文本编辑器,因为是未接触过的前后端分离,所以遇到了新的问题 问题:因为UEditor需要与后端代码结合,即将配置文件config.json放在服务器端访问,但是项目运行前端无法上传图片,报后端配置文件初始化失败的错误,config.json如下            问题分析:前后端分离的项目中前端无权直接访... 阅读详情

简介

  • 项目采用前后端分离,故通过jsp+java的方式实现UEditor的集成

1. 官网下载ueditor资源,完整版

https://ueditor.baidu.com/website/download.html

2. 把相应文件拷贝到前端项目(net,php,jsp文件夹这里用不到)

前端目录结构

3. 把jsp下面的源码,以及config.json文件拷贝到后台项目

后台目录

4. 修改前台配置

4.1 页面

<script type="text/javascript" src="lib/config.js"></script>
<script type="text/javascript" charset="utf-8" src="lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="lib/ueditor/1.4.3/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<div class="formControls col-xs-8">
    <input name="text" id="text" value="" type="hidden"/>
     <script id="editor" type="text/plain"></script>
</div>

初始化

<script>
   var content = "";
   var editor;
   UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
   UE.Editor.prototype.getActionUrl = function(action) {
   	//只有在自己写后台代码实现的时候才需要这一块儿
       if (action == 'uploadimage' /*|| action == 'uploadscrawl'*/ ) {
           return domainDb + "operate-db/ueditor/uploadimage";
       } else {
           return this._bkGetActionUrl.call(this, action);
       }
   }
   $(function () {
       $("input[name='operator']").val(userName);
       editor = UE.getEditor('editor');    //获取富文本
       //初始化编辑器 (该处用于设置编辑器回显值)
       editor.ready(function () {
           editor.setContent(content);
       });
   })
   </script>

4.2 config.js路径配置

//UEditor图片上传用到
var domainPage = "http://localhost:63342/operate-page/";
var domainDb = "http://localhost:8081/";

4.3 修改ueditor.config.js

在这里插入图片描述

4.4 修改ueditor.all.js

//设置图片最大宽度,以免撑出滚动条
 'img{max-width:100%;}' +

在这里插入图片描述

5. 修改后台配置

5.1 配置application-dev.yml中路径

systemconfig:
##服务器路径
#static_server_path: /usr/local/operate/static
#static_server_domain: http://118.126.142.184:8080/static
#config_json_path: /usr/local/tomcat-1/webapps/operate-db/WEB-INF/classes/config.json
##本地路径
##上传路径
static_server_path: D:\java\apache-tomcat-7.0.91\webapps\tenxSteel4\pages\static
##读取路径
static_server_domain: http://localhost:8085/tenxSteel4/pages/static
config_json_path: src/main/resources/config.json

5.2 SystemConfig工具类读取dev配置文件中的路径

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import tenx.operate.common.util.StringUtils;

import java.util.ResourceBundle;

@Configuration
public class SystemConfig {
   // 抽数据URL
  	public static String URL;
   /**
   * 数据库名称
   */
   public static String STATIC_SEVER_PATH;
   public static String STATIC_SEVER_DOMAIN;
   public static String CONFIG_JSON_PATH;
   @Value("${systemconfig.static_server_path}")
   public void setStaticServerPath(String staticServerPath) {
       SystemConfig.STATIC_SEVER_PATH = staticServerPath;
   }

   @Value("${systemconfig.config_json_path}")
   public void setConfigJsonPath(String configJsonPath) { SystemConfig.CONFIG_JSON_PATH = configJsonPath;
   }

   @Value("${systemconfig.static_server_domain}")
   public void setStaticSeverDomain(String staticServerDomain) { SystemConfig.STATIC_SEVER_DOMAIN = staticServerDomain;
   }

   /**
    * 转换静态资源路径
    * @param path
    * @return
    */
   public static String convertToUrl(String path){

       if(StringUtils.isNullOrEmpty(path)){
           return path;
       }
       return path.replaceAll("fs:",STATIC_SEVER_DOMAIN);
   }

   public static String convertToFile(String path){

       if(StringUtils.isNullOrEmpty(path)){
           return path;
       }
       return path.replaceAll("fs:",STATIC_SEVER_PATH);
   }
}

5.3 修改ConfigManager

  • 修改rootPath为dev中配置的图片上传路径
    originalPath为dev中配置的config.json所在的路径
    注:Linux为/usr/local/tomcat-1/webapps/operate-db/WEB-INF/classes/config.json
    本地环境为:src/main/resources/config.json
    在这里插入图片描述

5.4 修改BinaryUploader中的save方法

  • 如果不做修改的话上传会报错(未找到上传数据)
    原因:SpringMVC框架对含字节流的request进行了处理,此处传的是处理过的request,故获取不到字节流。
    故修改原有代码,采用SpringMVC框架的解析器multipartResolver
    public static final State save(HttpServletRequest request, Map<String, Object> conf) {
    	// FileItemStream fileStream = null;
    	// boolean isAjaxUpload = request.getHeader( "X_Requested_With" ) != null;
    
    	if (!ServletFileUpload.isMultipartContent(request)) {
    		return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT);
    	}
    
    	// ServletFileUpload upload = new ServletFileUpload(
    	// 	new DiskFileItemFactory());
    	//
    	// if ( isAjaxUpload ) {
    	//     upload.setHeaderEncoding( "UTF-8" );
    	// }
    
    	try {
    		// FileItemIterator iterator = upload.getItemIterator(request);
    		//
    		// while (iterator.hasNext()) {
    		// 	fileStream = iterator.next();
    		//
    		// 	if (!fileStream.isFormField())
    		// 		break;
    		// 	fileStream = null;
    		// }
    		//
    		// if (fileStream == null) {
    		// 	return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
    		// }
    		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    		MultipartFile multipartFile = multipartRequest.getFile(conf.get("fieldName").toString());
    		if(multipartFile==null){
    			return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
    		}
    
    		String savePath = (String) conf.get("savePath");
    		//String originFileName = fileStream.getName();
    		String originFileName = multipartFile.getOriginalFilename();
    		String suffix = FileType.getSuffixByFilename(originFileName);
    
    		originFileName = originFileName.substring(0,
    				originFileName.length() - suffix.length());
    		savePath = savePath + suffix;
    
    		long maxSize = ((Long) conf.get("maxSize")).longValue();
    
    		if (!validType(suffix, (String[]) conf.get("allowFiles"))) {
    			return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
    		}
    
    		savePath = PathFormat.parse(savePath, originFileName);
    
    		String physicalPath = (String) conf.get("rootPath") + savePath;
    
    		//InputStream is = fileStream.openStream();
    		InputStream is = multipartFile.getInputStream();
    		State storageState = StorageManager.saveFileByInputStream(is,
    				physicalPath, maxSize);
    		is.close();
    
    		if (storageState.isSuccess()) {
    			storageState.putInfo("url", PathFormat.format(savePath));
    			storageState.putInfo("type", suffix);
    			storageState.putInfo("original", originFileName + suffix);
    		}
    
    		return storageState;
    		// } catch (FileUploadException e) {
    		// 	return new BaseState(false, AppInfo.PARSE_REQUEST_ERROR);
    	} catch (IOException e) {
    	}
    	return new BaseState(false, AppInfo.IO_ERROR);
    }
    

5.5 修改config.json

/* 前后端通信相关的配置,注释只允许使用多行方式 */
{
   /*服务器路径:http://118.126.142.184:8080/static*/
   /*本地路径:http://localhost:8085/tenxSteel4/pages/static*/
   /* 上传图片配置项 */
   "imageActionName": "uploadimage", /* 执行上传图片的action名称 */
   "imageFieldName": "upfile", /* 提交的图片表单名称 */
   "imageMaxSize": 2048000, /* 上传大小限制,单位B */
   "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 上传图片格式显示 */
   "imageCompressEnable": true, /* 是否压缩图片,默认是true */
   "imageCompressBorder": 600, /* 图片压缩最长边限制 */
   "imageInsertAlign": "none", /* 插入的图片浮动方式 */
   "imageUrlPrefix": "http://localhost:8085/tenxSteel4/pages/static", /* 图片访问路径前缀 */
   "imagePathFormat": "/attachment/image/{yyyy}/{mm}/{dd}/{hh}/{ii}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
   /* {filename} 会替换成原文件名,配置这项需要注意中文乱码问题 */
   /* {rand:6} 会替换成随机数,后面的数字是随机数的位数 */
   /* {time} 会替换成时间戳 */
   /* {yyyy} 会替换成四位年份 */
   /* {yy} 会替换成两位年份 */
   /* {mm} 会替换成两位月份 */
   /* {dd} 会替换成两位日期 */
   /* {hh} 会替换成两位小时 */
   /* {ii} 会替换成两位分钟 */
   /* {ss} 会替换成两位秒 */
   /* 非法字符 \ : * ? " < > | */
   /* 具请体看线上文档: fex.baidu.com/ueditor/#use-format_upload_filename */

   /* 涂鸦图片上传配置项 */
   "scrawlActionName": "uploadscrawl", /* 执行上传涂鸦的action名称 */
   "scrawlFieldName": "upfile", /* 提交的图片表单名称 */
   "scrawlPathFormat": "/attachment/image/{yyyy}/{mm}/{dd}/{hh}/{ii}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
   "scrawlMaxSize": 2048000, /* 上传大小限制,单位B */
   /*"scrawlUrlPrefix": "http://localhost:8085/tenxSteel4/pages/tenxSteel4/pages/static/",*/ /* 图片访问路径前缀 */
   "scrawlUrlPrefix": "http://localhost:8085/tenxSteel4/pages/static", /* 图片访问路径前缀 */
   "scrawlInsertAlign": "none",

   /* 截图工具上传 */
   "snapscreenActionName": "uploadimage", /* 执行上传截图的action名称 */
   "snapscreenPathFormat": "/static/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
   "snapscreenUrlPrefix": "http://localhost:8085/tenxSteel4/pages/static", /* 图片访问路径前缀 */
   "snapscreenInsertAlign": "none", /* 插入的图片浮动方式 */

   /* 抓取远程图片配置 */
   "catcherLocalDomain": ["127.0.0.1", "localhost", "img.baidu.com"],
   "catcherActionName": "catchimage", /* 执行抓取远程图片的action名称 */
   "catcherFieldName": "source", /* 提交的图片列表表单名称 */
   "catcherPathFormat": "/attachment/image/{yyyy}/{mm}/{dd}/{hh}/{ii}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
   "catcherUrlPrefix": "http://localhost:8085/tenxSteel4/pages/static", /* 图片访问路径前缀 */
   "catcherMaxSize": 2048000, /* 上传大小限制,单位B */
   "catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 抓取图片格式显示 */

   /* 上传视频配置 */
   "videoActionName": "uploadvideo", /* 执行上传视频的action名称 */
   "videoFieldName": "upfile", /* 提交的视频表单名称 */
   "videoPathFormat": "/attachment/image/{yyyy}/{mm}/{dd}/{hh}/{ii}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
   "videoUrlPrefix": "http://localhost:8085/tenxSteel4/pages/static", /* 视频访问路径前缀 */
   "videoMaxSize": 102400000, /* 上传大小限制,单位B,默认100MB */
   "videoAllowFiles": [
       ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
       ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"], /* 上传视频格式显示 */

   /* 上传文件配置 */
   "fileActionName": "uploadfile", /* controller里,执行上传视频的action名称 */
   "fileFieldName": "upfile", /* 提交的文件表单名称 */
   "filePathFormat": "/attachment/image/{yyyy}/{mm}/{dd}/{hh}/{ii}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
   "fileUrlPrefix": "http://localhost:8085/tenxSteel4/pages/static", /* 文件访问路径前缀 */
   "fileMaxSize": 51200000, /* 上传大小限制,单位B,默认50MB */
   "fileAllowFiles": [
       ".png", ".jpg", ".jpeg", ".gif", ".bmp",
       ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
       ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
       ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
       ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
   ], /* 上传文件格式显示 */

   /* 列出指定目录下的图片 */
   "imageManagerActionName": "listimage", /* 执行图片管理的action名称 */
   /*"imageManagerListPath": "/static/upload/image/",*/ /* 指定要列出图片的目录 */
   "imageManagerListPath": "/attachment/image/{yyyy}/{mm}/{dd}/{hh}/{ii}/{time}{rand:6}", /* 指定要列出图片的目录 */
   "imageManagerListSize": 20, /* 每次列出文件数量 */
   "imageManagerUrlPrefix": "http://localhost:8085/tenxSteel4/pages/static", /* 图片访问路径前缀 */
   "imageManagerInsertAlign": "none", /* 插入的图片浮动方式 */
   "imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 列出的文件类型 */

   /* 列出指定目录下的文件 */
   "fileManagerActionName": "listfile", /* 执行文件管理的action名称 */
   /*"fileManagerListPath": "/static/upload/file/",*/ /* 指定要列出文件的目录 */
   "fileManagerListPath": "/attachment/image/{yyyy}/{mm}/{dd}/{hh}/{ii}/{time}{rand:6}", /* 指定要列出文件的目录 */
   "fileManagerUrlPrefix": "http://localhost:8085/tenxSteel4/pages/static", /* 文件访问路径前缀 */
   "fileManagerListSize": 20, /* 每次列出文件数量 */
   "fileManagerAllowFiles": [
       ".png", ".jpg", ".jpeg", ".gif", ".bmp",
       ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
       ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
       ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
       ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
   ] /* 列出的文件类型 */
}

5.6UeditorController

package tenx.operate.db.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import com.baidu.ueditor.ActionEnter;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import tenx.operate.db.config.SystemConfig;
import tenx.operate.db.config.upload.IUploader;

/**
 * @author: dyf
 * @version: v1.0
 * @date:2019/4/9 18:10
 */
@Controller
@CrossOrigin
@RequestMapping("/ueditor")
public class UeditorController {
    @Autowired
    private IUploader uploader;

    @RequestMapping("/config")
    public void config(HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException, JSONException{
        response.setContentType("application/json");
        String rootPath = request.getSession().getServletContext().getRealPath("/");
        try {
            //
            ActionEnter actionEnter = new ActionEnter(request, rootPath);
            String exec=actionEnter.exec();
            PrintWriter writer = response.getWriter();
            writer.write(exec);
            writer.flush();
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        };
    }
   @RequestMapping("/uploadimage")
   @ResponseBody
   public Map<String,Object> uploadImage(HttpServletRequest request, @RequestParam(value = "upfile",required = true) MultipartFile multipartFile){
       Map<String,Object> res = new HashMap<>();
       try{
           //封装的图片上传方法
           String path = this.uploader.upload(multipartFile.getInputStream(), SystemConfig.STATIC_SEVER_PATH,"image",
                   multipartFile.getOriginalFilename());
           String path1 = SystemConfig.convertToUrl(path);
           res.put("url", path1);//上传的图片路径
           res.put("state", "SUCCESS");
           res.put("title", multipartFile.getOriginalFilename());
           res.put("original", multipartFile.getOriginalFilename());
           return res ;
       }catch(Exception e){
           e.printStackTrace();
           return res;
       }
   }
}

5.7 pom文件添加相关依赖

<!-- 上传组件包 -->
   <dependency>
       <groupId>commons-fileupload</groupId>
       <artifactId>commons-fileupload</artifactId>
       <version>1.3.1</version>
   </dependency>
   <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
       <!--<version>1.3.2</version>-->
       <version>2.4</version>
   </dependency>
   <dependency>
       <groupId>commons-codec</groupId>
       <artifactId>commons-codec</artifactId>
       <version>1.9</version>
   </dependency>
   <dependency>
       <groupId>org.json</groupId>
       <artifactId>json</artifactId>
       <version>20180813</version>
   </dependency>

5.8 LocalUploader

import org.springframework.stereotype.Service;
import tenx.operate.common.util.DateUtil;
import tenx.operate.common.util.FileUtil;
import tenx.operate.common.util.StringUtils;

import java.io.InputStream;
import java.util.Calendar;
import java.util.Date;

/**
 * 文件上传具体实现类
 */
@Service("uploader")
public class LocalUploader implements IUploader {
    @Override
    public String upload(InputStream stream,String static_server_path, String subFolder, String fileName) {
        /**
         * 参数校验
         */
        if(stream==null || subFolder == null){
            throw new IllegalArgumentException("file or filename object is null");
        }
        if(!FileUtil.isAllowUpImg(fileName)){
            throw new IllegalArgumentException("不被允许的上传文件类型");
        }
        /**
         * 组合文件名
         */
        String ext = FileUtil.getFileExt(fileName);
        fileName = DateUtil.toString(new Date(), "mmss") + StringUtils.getRandStr(4) + "." + ext;
        String filePath =  static_server_path + "/attachment/";
        if(subFolder!=null){
            filePath+=subFolder +"/";
        }
        String timePath=this.getTimePath();
        String path  ="fs:"+ "/attachment/" +(subFolder==null?"":subFolder)+"/"+timePath+"/"+fileName;
        filePath +=timePath;
        filePath += fileName;
        /**
         * 写入文件
         */
        FileUtil.write(stream, filePath);
        return path;
    }
    /**
     * 上传app
     */
    @Override
    public String uploadApk(InputStream stream,String static_server_path,String subFolder,
                            String fileName) {
        /**
         * 参数校验
         */
        if(stream==null){
            throw new IllegalArgumentException("file or filename object is null");
        }
        if(subFolder == null){
            throw new IllegalArgumentException("subFolder is null");
        }

        // String name = null;
        String filePath = "";
        // String ext = FileUtil.getFileExt(fileName);
        // name = DateUtil.toString(new Date(), "mmss") + StringUtils.getRandStr(4) + "." + ext;

        filePath = static_server_path+ "/attachment/";
        if(subFolder!=null){
            filePath+=subFolder +"/";
        }
        String timePath=this.getTimePath();
        String path  ="fs:"+ "/attachment/" +(subFolder==null?"":subFolder)+"/"+timePath+"/"+fileName;
        filePath += timePath;
        filePath += fileName;
        FileUtil.createFile(stream, filePath);
        return path;
    }
    private String getTimePath(){
        Calendar now = Calendar.getInstance();
        int year=now.get(Calendar.YEAR);
        int month=now.get(Calendar.MONTH) + 1;
        int date=now.get(Calendar.DAY_OF_MONTH);
        //Calendar.HOUR 12小时制  Calendar.DAY_OF_MONTH 24小时制
        int hour=now.get(Calendar.HOUR_OF_DAY);
        int minute=now.get(Calendar.MINUTE);
        String filePath="";
        if(year!=0){
            filePath+=year+"/";
        }
        if(month!=0){
            filePath+=(month<10?("0"+month):month)+"/";
        }
        if(date!=0){
            filePath+=(date<10?("0"+date):date)+"/";
        }
        if(hour!=0){
            filePath+=(hour<10?("0"+hour):hour)+"/";
        }
        if(minute!=0){
            filePath+=(minute<10?("0"+minute):minute)+"/";
        }
        return  filePath;
    }
}

5.9 IUploader

public interface IUploader {
   /**
    *
    * @param stream	文件流
    * @param  static_server_path 地址
    * @param subFolder	子文件夹
    * @param fileName	 图片名称
    * @return
    */
   public String upload(InputStream stream, String static_server_path, String subFolder, String fileName);
   /**
    * 上传app安装包
    * @param stream 文件流
    * @param static_server_path 地址
    * @param subFolder 子文件夹
    * @param fileName 文件名称
    * @return
    */
   public String uploadApk(InputStream stream, String static_server_path, String subFolder, String fileName);
}

5.10 FileUtil

import org.springframework.web.multipart.MultipartFile;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import org.apache.commons.io.FileUtils;
/**
 * 上传工具类
 */
public class FileUtil {

    private FileUtil() {
    }

    public static BufferedImage toBufferedImage(Image image) {
        if (image instanceof BufferedImage) {
            return (BufferedImage) image;
        }

        // This code ensures that all the pixels in the image are loaded
        image = new ImageIcon(image).getImage();

        // Determine if the image has transparent pixels; for this method's
        // implementation, see e661 Determining If an Image Has Transparent
        // Pixels
        // boolean hasAlpha = hasAlpha(image);

        // Create a buffered image with a format that's compatible with the
        // screen
        BufferedImage bimage = null;
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        try {
            // Determine the type of transparency of the new buffered image
            int transparency = Transparency.OPAQUE;
			/*
			 * if (hasAlpha) { transparency = Transparency.BITMASK; }
			 */

            // Create the buffered image
            GraphicsDevice gs = ge.getDefaultScreenDevice();
            GraphicsConfiguration gc = gs.getDefaultConfiguration();
            bimage = gc.createCompatibleImage(image.getWidth(null),image.getHeight(null), transparency);
        } catch (HeadlessException e) {
            // The system does not have a screen
        } catch (Exception e){
            e.printStackTrace();
        }

        if (bimage == null) {
            // Create a buffered image using the default color model
            int type = BufferedImage.TYPE_INT_RGB;
            // int type = BufferedImage.TYPE_3BYTE_BGR;//by wang
			/*
			 * if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; }
			 */
            bimage = new BufferedImage(image.getWidth(null),image.getHeight(null), type);
        }

        // Copy image to buffered image
        Graphics g = bimage.createGraphics();

        // Paint the image onto the buffered image
        g.drawImage(image, 0, 0, null);
        g.dispose();

        return bimage;
    }


    public static void createFile(InputStream in, String filePath) {
        if(in==null) throw new RuntimeException("create file error: inputstream is null");
        int potPos = filePath.lastIndexOf('/') + 1;
        String folderPath = filePath.substring(0, potPos);
        createFolder(folderPath);
        FileOutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream(filePath);
            byte[] by = new byte[1024];
            int c;
            while ((c = in.read(by)) != -1) {
                outputStream.write(by, 0, c);
            }
        } catch (IOException e) {
            e.getStackTrace().toString();
        }
        try {
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /**
     * 是否是允许上传文件
     *
     * @param logoFileName
     * @return
     */
    public static boolean isAllowUp(String logoFileName) {
        logoFileName = logoFileName.toLowerCase();
        String allowTYpe = "gif,jpg,jpeg,bmp,swf,png,rar,doc,docx,xls,xlsx,pdf,zip,ico,txt,mp4";
        if (!logoFileName.trim().equals("") && logoFileName.length() > 0) {
            String ex = logoFileName.substring(logoFileName.lastIndexOf(".") + 1, logoFileName.length());
			//return allowTYpe.toString().indexOf(ex) >= 0;
            //lzf edit 20110717
            //解决只认小写问题
            //同时加入jpeg扩展名/png扩展名
            return allowTYpe.toUpperCase().indexOf(ex.toUpperCase()) >= 0;
        } else {
            return false;
        }
    }
    /**
     * 是否是允许上传的图片
     * @param imgFileName
     * @return
     */
    public static boolean isAllowUpImg(String imgFileName){
        imgFileName = imgFileName.toLowerCase();
        String allowTYpe = "jpg,png,jpeg";
        if (!imgFileName.trim().equals("") && imgFileName.length() > 0) {
            String ex = imgFileName.substring(imgFileName.lastIndexOf(".") + 1, imgFileName.length());
            return allowTYpe.toUpperCase().indexOf(ex.toUpperCase()) >= 0;
        } else {
            return false;
        }
    }
    /**
     * 是否是允许上传app安装包
     * @param apkFileName
     * @return
     */
    public static boolean isAllowUpApk(String apkFileName){
        apkFileName = apkFileName.toLowerCase();
        String allowTYpe = "apk";
        if (!apkFileName.trim().equals("") && apkFileName.length() > 0) {
            String ex = apkFileName.substring(apkFileName.lastIndexOf(".") + 1, apkFileName.length());
            return allowTYpe.toUpperCase().indexOf(ex.toUpperCase()) >= 0;
        } else {
            return false;
        }
    }
    /**
     * 是否是允许上传Excel
     *
     * @param logoFileName
     * @return
     */
    public static boolean isAllowUpExcel(String logoFileName) {
        logoFileName = logoFileName.toLowerCase();
        String allowTYpe = "xls";
        if (!logoFileName.trim().equals("") && logoFileName.length() > 0) {
            String ex = logoFileName.substring(logoFileName.lastIndexOf(".") + 1, logoFileName.length());
			return allowTYpe.toString().indexOf(ex) >= 0;
            //lzf edit 20110717
            //解决只认小写问题
            //同时加入jpeg扩展名/png扩展名
            return allowTYpe.toUpperCase().indexOf(ex.toUpperCase()) >= 0;
        } else {
            return false;
        }
    }
    /**
     * 把内容写入文件
     *
     * @param filePath
     * @param fileContent
     */
    public static void write(String filePath, String fileContent) {

        try {
            FileOutputStream fo = new FileOutputStream(filePath);
            OutputStreamWriter out = new OutputStreamWriter(fo, "UTF-8");

            out.write(fileContent);

            out.close();
        } catch (IOException ex) {

            System.err.println("Create File Error!");
            ex.printStackTrace();
        }
    }


    /**
     * 将inputstream写入文件
     * @param file 文件
     * @param path 要写入的文件路径
     */
    public static void write(MultipartFile file, String path){
        try {
            FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    /**
     * 将inputstream写入文件
     * @param stream 文件流
     * @param path 要写入的文件路径
     */
    public static void write(InputStream stream,String path){
        try {
            FileUtils.copyInputStreamToFile(stream, new File(path));
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
    /**
     * 读取文件内容 默认是UTF-8编码
     *
     * @param filePath
     * @return
     */
    public static String read(String filePath, String code) {
        if (code == null || code.equals("")) {
            code = "UTF-8";
        }
        String fileContent = "";
        File file = new File(filePath);
        try {
            InputStreamReader read = new InputStreamReader(new FileInputStream(
                    file), code);
            BufferedReader reader = new BufferedReader(read);
            String line;
            while ((line = reader.readLine()) != null) {
                fileContent = fileContent + line + "\n";
            }
            read.close();
            read = null;
            reader.close();
            read = null;
        } catch (Exception ex) {
            ex.printStackTrace();
            fileContent = "";
        }
        return fileContent;
    }

    /**
     * 删除文件或文件夹
     *
     * @param filePath
     */
    public static void delete(String filePath) {
        try {
            File file = new File(filePath);
            if (file.exists()){
                if(file.isDirectory()){
                    FileUtils.deleteDirectory(file);
                }else{
                    file.delete();
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static boolean exist(String filepath) {
        File file = new File(filepath);

        return file.exists();
    }

    /**
     * 创建文件夹
     *
     * @param filePath
     */
    public static void createFolder(String filePath) {
        try {
            File file = new File(filePath);
            if (!file.exists()) {
                file.mkdirs();
            }
        } catch (Exception ex) {
            System.err.println("Make Folder Error:" + ex.getMessage());
        }
    }

    /**
     * 重命名文件、文件夹
     * @param from
     * @param to
     */
    public static void renameFile(String from, String to) {
        try {
            File file = new File(from);
            if(file.exists()){
                file.renameTo(new File(to));
            }
        }catch (Exception ex) {
            System.err.println("Rename File/Folder Error:" + ex.getMessage());
        }
    }

    /**
     * 得到文件的扩展名
     *
     * @param fileName
     * @return
     */
    public static String getFileExt(String fileName) {

        int potPos = fileName.lastIndexOf('.') + 1;
        String type = fileName.substring(potPos, fileName.length());
        return type;
    }

    /**
     * 通过File对象创建文件
     *
     * @param file
     * @param filePath
     */
    public static void createFile(File file, String filePath) {
        int potPos = filePath.lastIndexOf('/') + 1;
        String folderPath = filePath.substring(0, potPos);
        createFolder(folderPath);
        FileOutputStream outputStream = null;
        FileInputStream fileInputStream = null;
        try {
            outputStream = new FileOutputStream(filePath);
            fileInputStream = new FileInputStream(file);
            byte[] by = new byte[1024];
            int c;
            while ((c = fileInputStream.read(by)) != -1) {
                outputStream.write(by, 0, c);
            }
        } catch (IOException e) {
            e.getStackTrace().toString();
        }
        try {
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            fileInputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String readFile(String resource) {
        InputStream stream = getResourceAsStream(resource);
        String content = readStreamToString(stream);

        return content;

    }

    public static InputStream getResourceAsStream(String resource) {
        String stripped = resource.startsWith("/") ? resource.substring(1)
                : resource;

        InputStream stream = null;
        ClassLoader classLoader = Thread.currentThread()
                .getContextClassLoader();
        if (classLoader != null) {
            stream = classLoader.getResourceAsStream(stripped);

        }

        return stream;
    }

    public static String readStreamToString(InputStream stream) {
        String fileContent = "";

        try {
            InputStreamReader read = new InputStreamReader(stream, "utf-8");
            BufferedReader reader = new BufferedReader(read);
            String line;
            while ((line = reader.readLine()) != null) {
                fileContent = fileContent + line + "\n";
            }
            read.close();
            read = null;
            reader.close();
            read = null;
        } catch (Exception ex) {
            fileContent = "";
        }
        return fileContent;
    }

    /**
     * delete file folder
     *
     * @param path
     */
    public static void removeFile(File path) {

        if (path.isDirectory()) {
            try {
                FileUtils.deleteDirectory(path);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

    public static void copyFile(String srcFile,String destFile){
        try {
            if(FileUtil.exist(srcFile)){
                FileUtils.copyFile(new File(srcFile),new File( destFile ));
            }
        } catch (IOException e) {

            e.printStackTrace();
        }
    }

    public static void copyFolder(String sourceFolder, String destinationFolder)
    {
        ////System.out.println("copy " + sourceFolder + " to " + destinationFolder);
        try{
            File sourceF = new File(sourceFolder);
            if (sourceF.exists())
                FileUtils.copyDirectory(new File(sourceFolder), new File(
                        destinationFolder));
        }catch(Exception e){
            e.printStackTrace();
            throw new RuntimeException("copy file error");
        }
    }


    /**
     * 拷贝源文件夹至目标文件夹
     * 只拷贝新文件
     * @param sourceFolder
     * @param targetFolder
     */
    public static void copyNewFile(String sourceFolder, String targetFolder){
        try{
            File sourceF = new File(sourceFolder);

            if(!targetFolder.endsWith("/")) targetFolder=targetFolder+"/";

            if (sourceF.exists()){
                File[] filelist = sourceF.listFiles();
                for(File f:filelist){
                    File targetFile = new File(targetFolder+f.getName());

                    if(  f.isFile()){
                        //如果目标文件比较新,或源文件比较新,则拷贝,否则跳过
                        if(!targetFile.exists() || FileUtils.isFileNewer(f, targetFile)){
                            FileUtils.copyFileToDirectory(f, new File(targetFolder));
                            ////System.out.println("copy "+ f.getName());
                        }else{
                            //	//System.out.println("skip  "+ f.getName());
                        }
                    }
                }
            }


        }catch(Exception e){
            e.printStackTrace();
            throw new RuntimeException("copy file error");
        }
    }

	/*
	public static void unZip(String zipPath,String targetFolder,boolean cleanZip){
		File folderFile =new File(targetFolder);
		File zipFile = new File(zipPath);
		Project prj = new Project();
		Expand expand = new Expand();
		expand.setEncoding("UTF-8");
		expand.setProject(prj);
		expand.setSrc(zipFile);
		expand.setOverwrite(true);
		expand.setDest(folderFile);
		expand.execute();

		if(cleanZip){
			//清除zip包
			Delete delete = new Delete();
			delete.setProject(prj);
			delete.setDir(zipFile);
			delete.execute();
		}
	}
	*/
}

5.11 DateUtil

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 日期工具类
 */
public class DateUtil {
    /**
     * 获取某个日期days天后的日期
     * @param date 日期
     * @param days 时间间隔 天数
     * @return
     */
    public static Date getDateAfterDays(Date date,int days){
        Calendar  calendar  =  Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.DATE,days);
        return calendar.getTime();
    }

    /**
     * 获取今天凌晨日期
     * @return date类型
     */
    public static Date getToday(){
        Date now =new Date();
        Calendar c = Calendar.getInstance();
        c.setTime(now);
        c.set(Calendar.HOUR_OF_DAY,0);
        c.set(Calendar.MINUTE,0);
        c.set(Calendar.SECOND,0);
        c.set(Calendar.MILLISECOND,0);
        // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return c.getTime();
    }

    /**
     * 转换字符串为日期格式
     * @param dateStr 时间字符串
     * @param pattern 格式化标准
     * @return
     */
    public static Date toDate(String dateStr,String pattern){
        if (StringUtils.isNullOrEmpty(dateStr)){
            return null;
        }
        if (pattern == null){
            pattern ="yyyy-MM-dd HH:mm:ss";
        }
        Date date = null;
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        try {
            date =  sdf.parse(dateStr);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return date;
    }

    /**
     * 把日期转换成字符串型
     * @param date 日期
     * @param pattern 格式化标准
     * @return
     */
    public static String toString(Date date, String pattern){
        if(date == null){
            return "";
        }
        if(pattern == null){
            pattern = "yyyy-MM-dd";
        }
        String dateString = "";
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        try {
            dateString = sdf.format(date);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return dateString;
    }

    /**
     * 拿time1和time2比较</br>
     * time1和time2比较 : <1分钟时显示为刚刚;</br>
     * time1和time2比较 : ≥1分钟,<1小时时,显示为:*分钟前;</br>
     * time1和time2比较 : ≥1小时,<1天时,显示为:*小时前;</br>
     * time1和time2比较 : ≥1天时,显示格式:YY-MM-DD
     * @param time1 一般是评论日期,文章日期
     * @param time2 一般是当前时间
     * @return 指定的时间
     */
    public static String compare(Date time1, Long time2){
        Long diff = time2 - time1.getTime();
        if(diff >=3600000L && diff < 86400000L){
            return (diff/3600000L)+"小时前";
        } else if (diff >= 60000L && diff <3600000L){
            return (diff/60000L)+"分钟前";
        } else if (diff < 60000L){
            return "刚刚";
        } else {
            return new SimpleDateFormat("yyyy-MM-dd").format(time1);
        }
    }

    private static void convertWeekByDate(Date time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //设置时间格式 Calendar cal = Calendar.getInstance(); cal.setTime(time); //判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了 int dayWeek = cal.get(Calendar.DAY_OF_WEEK);//获得传入日期是一个星期的第几天 if(1 == dayWeek) { cal.add(Calendar.DAY_OF_MONTH, -1); } System.out.println("要计算日期为:"+sdf.format(cal.getTime())); //输出要计算日期 cal.setFirstDayOfWeek(Calendar.MONDAY);//设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一 int day = cal.get(Calendar.DAY_OF_WEEK);//获得传入日期是一个星期的第几天 cal.add(Calendar.DATE, cal.getFirstDayOfWeek()-day);//根据日历的规则,给传入日期减去星期几与一个星期第一天的差值 String Monday = sdf.format(cal.getTime()); System.out.println("所在周星期一的日期:"+Monday); cal.add(Calendar.DATE, 1); String Tuesday = sdf.format(cal.getTime()); System.out.println("所在周星期二的日期:"+Tuesday); cal.add(Calendar.DATE, 1); String Wednesday = sdf.format(cal.getTime()); System.out.println("所在周星期三的日期:"+Wednesday); cal.add(Calendar.DATE, 1); String Thursday = sdf.format(cal.getTime()); System.out.println("所在周星期四的日期:"+Thursday); cal.add(Calendar.DATE, 1); String Friday = sdf.format(cal.getTime()); System.out.println("所在周星期五的日期:"+Friday); cal.add(Calendar.DATE, 1); String Saturday = sdf.format(cal.getTime()); System.out.println("所在周星期六的日期:"+Saturday); cal.add(Calendar.DATE, 1); String Sunday = sdf.format(cal.getTime()); System.out.println("所在周星期日的日期:"+Sunday); }

    }


        public static void main(String[] args) throws Exception{
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d1 = sdf.parse("2018-01-15 01:08:00");
        Date d2 = sdf.parse("2018-01-16 18:57:20");
        System.out.println(compare(d1,d2.getTime()));
    }

}

6. bug汇总

6.1 单图上传提示"上传错误",但是图片已经上传成功

  • 定位如下
    在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述
  • 全局搜索"上传错误",定位到simpleupload.loadError,form表单提交出现跨域的情况导致的,父页面http://localhost:63342/jianbang-page/hotSpot.html,子页面:http://localhost:8088/jianbang-report/ueditor/config?action=uploadimage。
    因为浏览器的保护机制,在跨域的情况下是不能读取iframe里的内容的。这是为了防止一个网站读取另一个网站里的信息。所以这就造成了UEditor在上传的时候因为读不到iframe内容而提示“上传错误”这种错觉,但实际上已经上传成功了。故此时通过iframe.contentWindow.document是读取不到子页面上传结果信息的。
    在这里插入图片描述在这里插入图片描述
  • 解决方案:舍弃callback回调,通过ajax提交的方式,在success中做上传后的处理逻辑
    注释掉原来form提交逻辑
    // domUtils.on(iframe, 'load', callback);
    // form.action = utils.formatUrl(imageActionUrl + (imageActionUrl.indexOf('?') == -1 ? '?':'&') + params);
    // form.submit();
    
  • 添加ajax提交方式
    var params = utils.serializeParam(me.queryCommandValue('serverparam')) || '';
    var action = utils.formatUrl(imageActionUrl + (imageActionUrl.indexOf('?') == -1 ? '?' : '&') + params);
    var formData = new FormData();
    formData.append("upfile", form[0].files[0] );
    $.ajax({
        url: action,
        type: 'POST',
        cache: false,
        data: formData,
        processData: false,
        contentType: false,
        success: function (data) {
            // data = JSON.parse(data);
            var link, loader,
                body = (iframe.contentDocument || iframe.contentWindow.document).body,
                result = body.innerText || body.textContent || '';
            link = me.options.imageUrlPrefix + data.url;
    
            if(data.state == 'SUCCESS' && data.url) {
                loader = me.document.getElementById(loadingId);
                loader.setAttribute('src', link);
                loader.setAttribute('_src', link);
                loader.setAttribute('title', data.title || '');
                loader.setAttribute('alt', data.original || '');
                loader.removeAttribute('id');
                domUtils.removeClasses(loader, 'loadingclass');
            } else {
                showErrorLoader && showErrorLoader(data.state);
            }
        	form.reset();
     }
    });
    
  • 此外,也可以通过重定向的方法,参考https://blog.youkuaiyun.com/lnkToKing/article/details/79091753
springboot2.0 前后端分离集成富文本编辑器UEditor ,配置文件上传 1.下载UEditor UEditor官方下载地址 本人选择了[1.4.3.3 Jsp 版本]; 解压后,找到index.html文件,可参看文件进行配置,并掌握对富文本编辑器的常用方法。 运行后的效果 如果不用上传文件,就不用往后看。 如果需要上传文件,点击图片或者视频上传 会提示后端配置项没有正常加载 2.配置spring boot2.0 后端代码,实现正常加载 后端代码目录结构如下 ... 阅读详情

相关推荐

前后端分离springboot整合ueditor并上传附件到腾讯云存储桶

1、下载Java源码https://ueditor.baidu.com/website/download.html 2、下载前端代码JSP,utf-8版 3、解压并打开下载的Java源码ueditor1_4_3_3包,按以下路径,将整个com包复制到你的项目中 4.解压并打开下载的ueditor1_4_3_3-utf8-jsp包,将config.json文件拷贝到项目的res...

米老鼠的博客 2466

前后端分离(Vue+Java)集成UEditor

前后端分离集成UEditor

caiyq_zq的博客 940

基于springboot+vue+element+ueditor实现前后端分离的富文本框实现

springboot+vue+ueditor的整合

Simle_MiMI的博客 1万+

UEditor 前后端分离

UEditor 前后端分离

gz775的专栏 255

从“盲控”到“预见”:聊聊永磁同步电机负载观测器(PMSM Load Observer)如何让控制更丝滑

本文深入探讨了永磁同步电机负载观测器(PMSM Load Observer)如何通过前馈补偿和转动惯量辨识技术实现智能抗扰控制。从传统‘盲控’到预见性调节,负载观测器显著减少转速波动和能耗,提升系统响应速度。文章详细解析了观测器算法架构、工程调参技巧及前沿发展趋势,为电机控制领域提供实用解决方案。

weixin_33737774的博客 406

SAP成本中心费用分割(KSS2)实战:从原理到月末调整全解析

本文详细解析了SAP成本中心费用分割(KSS2)的核心逻辑与实战操作,从成本要素分组配置到月末调整全流程。通过KSS2将初级成本要素按作业类型重新分类为次级成本要素,确保成本结算准确。文章还提供了常见错误处理方法和典型业务场景实战,帮助用户高效完成SAP成本结算。

weixin_29279101的博客 1264

VUE使用UEditor,前后端分离

VUE使用UEditor,前后端分离

qq_35770559的博客 825

超详细!动态规划详解分析(典型例题分析和对比,附源码)

为啥要使用动态规划?什么时候使用动态规划?以下是我的一些理解和心得,如果你感兴趣,就接着往下看吧。 对您有帮助的话记得给我点个赞哟! 动态规划的基本思想 动态规划(Dynamic Programming,DP)算法通常用于求解某种具有最优性质的问题。在这类问题中,可能会有许多可行解,每一个解都对应一个值,我们希望找到具有最优值的解。 动态规划算法与分治法类似,其基本思想也是将待求解的问题分解成若干个子问题,先求解子问题,然后从这些子问题的解中 得到原有问题的解。与分治法不同的是,动态规划经分解后得到的子问题

qq_44398094的博客 8万+

Ueditor后端Spring Boot,以及前后端分离配置上传图片(超级易懂)

一、前言 光哥我找了很多的ueditor富文本编辑器后端配置上传图片,我就说白话了,操蛋,网上写的真复杂,还下源码、改源码、源码代码复制到本地项目,我也看了一遍源码,源码大致就是给你写了一些上传的代码、和一些读取config.json的配置, 而且源码的上传保存路径是本地临时文件夹,一般保存图片都是放在第三方文件服务器、如果大家去改这个,很不推荐、一些小白可能到这里就卡死在这里了 最后我的要求很简...

2707

【计算机视觉】基于复杂环境下的车牌识别

本文针对复杂环境下(光照变化、车牌变形、噪声干扰)的车牌识别问题,提出了一套完整的优化方案。通过四个核心环节进行改进:1)采用CLAHE、同态滤波等技术优化光照处理;2)使用边缘检测和透视变换应对车牌变形;3)结合中值滤波和暗通道去噪算法消除干扰;4)改进字符分割与识别方法。文章提供了详细的Python实现代码,展示了从预处理到字符识别的完整流程,并通过多策略融合显著提升了复杂场景下的识别准确率。实验结果表明,该方法能有效应对各类复杂环境挑战,为实际应用提供了可靠解决方案。

2401_84149564的博客 1628

Java电商秒杀系统性能优化(一)——电商秒杀系统框架回顾

电商秒杀系统框架回顾项目简介外部依赖框架回顾项目要点项目中存在的问题小结 课程是免费的,课程地址如下:SpringBoot搭建电商秒杀项目,课程真的很棒,作者的思路很清晰,建议各位读者可以跟着视频练习一下这个项目; 项目简介 通过SpringBoot快速搭建的前后端分离的电商基础秒杀项目。项目通过应用领域驱动型的分层模型设计方式去完成:用户otp注册、登陆、查看、商品列表、进入商品详情以及倒计时秒...

ghw15221836342的博客 3722

Spring boot 整合Ueditor(百度编辑器) 简洁版(图片上传)

1、先给大家拜个早年! 看个效果图: 2、去百度官网下载UEditor。机票 3、下载下来是这样的: # config.json 配置文件(需要引用) # controller.jsp springboot默认不支持jsp的,所以在这里咱也不用。 # ueditor.config.js 这个需要,直接引入页面就行了。一共引入三个就行了 <!--...

cocosum 2161

【2025最新版】间接平差——以水准网平差为例 (python详细过程版)

水准网间接平差的python代码实现。博客长期更新,本文最新更新时间为:2025年5月20日。

点云侠的博客 1702

springboot+ueditor+OSS+若依框架+vue-cli3前后端分离

一、准备UEditor 在 官网下载合适的UEditor(这里使用的是jsp版本) 解压红色框部分是前端需要的\color{red}{红色框部分是前端需要的}红色框部分是前端需要的,jsp文件夹里面的是后台需要的\color{blue}{jsp文件夹里面的是后台需要的}jsp文件夹里面的是后台需要的 二、vue-ueditor-wrap组件 安装vue-ueditor-wrap npm i vue-ueditor-wrap 在main.js引入vue-ueditor-wrap import VueUedi

xyllp的博客 2749

LLC谐振变换器软启动,不只是“慢启动”,还是“智能启动”

LLC谐振变换器的软启动,不只是“慢慢来”,而是要在控制时序、限流、响应速度之间精妙权衡。而数字控制,特别是用查表法或混合信号法,为实现真正的“最佳轨迹”提供了可能。✨小Tips:如果你的系统成本敏感,选择查表法准没错;如果你的设计目标是超高速响应,那就上混合信号的高配方案!

weixin_43199439的博客 691

BLDC&PMSM电机控制器硬件设计工程(一)概述&需求&规划

这里是一个专注于电机控制器硬件工程的开放社区与知识仓库。我们的核心使命是分享、交流与共创,致力于解开无刷直流电机(BLDC)和永磁同步电机(PMSM)中、大功率控制器硬件设计,包括驱动IC选型,电流传感器选型,控制IC,母线电容计算,功率模块(IGBT、MOS管)选型以及大功率功率模块驱动电源设计。功率等级: 重点关注中等功率(如500W-10kW) 并向大功率(10kW以上) 延伸,探讨对应的功率器件(如MOSFET, IGBT, SiC)选型与驱动。

小幽余生不加糖 638

springBoot集成ueditor,前后端分离配置

更多内容请浏览本人博客 在前后端分离的前提下,配置ueditor实现文件上传(主要是图片和视频),并在编辑器中反显,注重后台接口的编写 目录结构 后端采用Java,目录结构如下: TIM截图20180202160257.png 项目github地址: https://github.com/weylanshi/UeditorSpringboot.git 前端采用的vue,目录结构如下:...

小石头记 644

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

springboot整合ueditor 前后端分离

1.下载ueditor,百度搜索ueditor,下载 前端用的是Jsp版,导入文件如下 由于要修改部分源码,所以后端用的源码版,导入文件如下 2.配置路径,用来找到json文件 配置前端ueditor.config.js,用来找到Controller 新建UeditorController,指定路径rootPath 用来找到config.json文件 @R...

weixin_30404405的博客 1040

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

ueditor在vue+springboot前后端分离项目图片上传配置踩坑总结

记录一下vue+springboot项目中ueditor上传图片配置踩的坑ueditor集成的基本配置VUE前端踩的坑注意*******************注意,下面是爬了一天的坑 ueditor集成的基本配置 网上有很多教程,具体的配置就先不说了。 https://www.cnblogs.com/ocean-sky/p/7132319.html 这个链接里面写的就非常详细。 VUE前端踩的坑...

Tianxiangp的博客 4842

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

springboot+html+ueditor 前后端分离使用方法

ueditor+springboot+html 前后端分离。配置思路。与java代码

qq_36286574的博客 806

推荐 - springboot2 整合 ueditor 富文本编辑器 并实现前后端分离

springboot2 整合 ueditor 富文本编辑器 并实现前后端分离

cjh的博客 1010

vue + Springboot 前后端分离集成UEditor

UEditor只提供JSP版本的后端入口代码。但是它提供了项目源码,因此我们可以根据业务需求来修改源代码。 现在开始集成UEditor  1、下载UEditor官网最新的jsp版本的包,下载完成解压之后得到一个utf8-jsp的文件夹,里面包含的内容如下: 除了jsp文件夹和index.html文件外,把所有的文件都复制到前台目录下的static里文件夹里,如下图: 2. 将编辑器...

qq_38960998的博客 8216

JAVA SpringBoot2 整合 ueditor 的 并实现前后端分离

1,下载 jsp 版本的 百度编辑器,点击此处下载 2,解压文件,解压后目录如下 3,我们将 jsp 目录暂时移动到别的地方,剩下的文件作为一个 H5 前端项目使用,笔者这边导入到 idea 进行开发,导入后如下 4,创建一个 springboot 项目,引入以下 maven 依赖 <!-- WEB 开发 --> &l...

weixin_30319097的博客 973

ueditor php前后端分离,Springmvc/SpringBoot VUE UEditor前后端分离

1、准备工作image.png1.2、将源码文件夹下的:⁨jsp⁩ / ⁨src⁩ / ⁨com⁩ / ⁨baidu⁩/ueditor 放入自己工程中,修改一些引入的错误1.3、将源码文件夹下的jsp⁩:config.js文件放入项目中webapp目录下的新建文件夹config中,如下图所示:image.png1.4、 另外由于在上一步中,把config.json文件放置到了src/main/we...

weixin_35886636的博客 308

SpringBoot2.1.6 前后端分离整合 UEditor

起因 在一个客户的前后端分离的管理系统中,客户希望要一个编辑功能丰富的富文本编辑器,前端人员翻来覆去最终找来了百度的UEditor 符合客户的要求,问题也随之而来,百度的这个富文本编辑器需要后端提供接口配置,前端人员就丢过来一个链接,说是需要后端配合提供一个,查看了百度官方提供UEditor 文档,看着挺简单的,官方提供的demo 是1.4.3.3 Jsp 版本 ,其中有两大坑 1、通过官方提供方...

爱新觉罗的博客 1184

SpringBoot2.1.6 前后端分离整合 UEditor(后端操作)

qqq

qq_45015129的博客 571
下一篇: CDH大数据集群搭建
YanfangDu
博客等级 码龄10年 4粉丝 4原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值