Commit d6edcef3 authored by m1991's avatar m1991

资讯模块数据——修改图片地址出现null问题

parent 39c85355
...@@ -42,7 +42,7 @@ public class UploadServiceImpl implements UploadService { ...@@ -42,7 +42,7 @@ public class UploadServiceImpl implements UploadService {
@Autowired @Autowired
private UsersMapper usersMapper; private UsersMapper usersMapper;
@Value("${file.upload.path:#{null}}") // @Value("${file.upload.path:#{null}}")
private String path; private String path;
/** /**
...@@ -152,10 +152,10 @@ public class UploadServiceImpl implements UploadService { ...@@ -152,10 +152,10 @@ public class UploadServiceImpl implements UploadService {
public List imageUpload(MultipartFile[] files, String zxField, String zxAddress,String inviteCode) { public List imageUpload(MultipartFile[] files, String zxField, String zxAddress,String inviteCode) {
//获取上传图片数量,打印在控制台 //获取上传图片数量,打印在控制台
System.out.println("上传图片数量" + files.length); System.out.println("上传图片数量" + files.length);
String zxUrl = new String();
//创建集合 //创建集合
List<Map<String, Object>> root = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> root = new ArrayList<Map<String, Object>>();
String fileName1=null; String fileName1=null;
String zxUrl=null;
// 要上传的目标文件存放的绝对路径 // 要上传的目标文件存放的绝对路径
// final String localPath = path; // final String localPath = path;
Long time = new Date().getTime(); Long time = new Date().getTime();
...@@ -167,6 +167,7 @@ public class UploadServiceImpl implements UploadService { ...@@ -167,6 +167,7 @@ public class UploadServiceImpl implements UploadService {
if (file.isEmpty()) { if (file.isEmpty()) {
System.out.println("上传图片为空,请重新上传"); System.out.println("上传图片为空,请重新上传");
} }
//判断上传文件格式 //判断上传文件格式
String fileType = file.getContentType(); String fileType = file.getContentType();
if (fileType.equals("image/jpeg") || fileType.equals("image/png")) { if (fileType.equals("image/jpeg") || fileType.equals("image/png")) {
...@@ -181,6 +182,7 @@ public class UploadServiceImpl implements UploadService { ...@@ -181,6 +182,7 @@ public class UploadServiceImpl implements UploadService {
//设置文件存储路径,可以存放在你想要指定的路径里面 //设置文件存储路径,可以存放在你想要指定的路径里面
String Path="/opt/upload/video/"; //上传图片存放位置 String Path="/opt/upload/video/"; //上传图片存放位置
zxUrl+=localPath+fileName+","; zxUrl+=localPath+fileName+",";
if (FileUtils.upload(file,Path, fileName)) { if (FileUtils.upload(file,Path, fileName)) {
//文件存放的相对路径(一般存放在数据库用于img标签的src) //文件存放的相对路径(一般存放在数据库用于img标签的src)
String relativePath ="用于判断是否图片上传成功,返回值有:"+fileName; String relativePath ="用于判断是否图片上传成功,返回值有:"+fileName;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment