1.在application.properties.xml中配置
# SpringBoot框架实现图片上传显示并保存地址到数据库
#spring boot上传文件大小限制
spring.http.multipart.max-file-size=200MB
spring.http.multipart.max-request-size=200MB
2.创建物品实体类productModel
package com.lyancafe.material.model;
/**
* @author scy 2018/8/22
*/
public class ProductModel {
private Integer id;
private String image;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
@Override
public String toString() {
return "ProductModel{" +
"id=" + id +
", image='" + image + '\'' +
'}';
}
}
3.创建ProductController
package com.lyancafe.material.controller;
import com.lyancafe.material.bo.ProductService;
import com.lyancafe.material.model.ProductModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
/**
* @author scy 2018/8/22
*/
@Controller
@RequestMapping("product")
public class ProductController {
@Autowired
private ProductServ