-
文件上傳和下載都是一件難題,今天我們的目的就是攻克這個難題
開始正題:
-
首先創建一個SpringBoot項目,導入thmeleaf模板引擎和Web
-
Service層代碼:
package com.zhang.upload_demo01.service;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
-
使用這個也可以 放回的信息更加詳細
package com.zhang.upload_demo02.service;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;