zoukankan      html  css  js  c++  java
  • 5.1团队冲刺04

    今天整输出图片

    还是根据路径,只不过路径是需要自己组装的

    public class Display {
    private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
    private static ImgService imgService = (ImgService) applicationContext.getBean("ImgServiceImpl");
    public static boolean displayImg(MultipartFile file){
    try {
    String path = CreatPath.creatPath(file);
    String hash = CreatPath.creatName();
    String name = file.getOriginalFilename();//上传文件的真实名称
    String suffixName = name.substring(name.lastIndexOf("."));//获取后缀名
    String fileName = hash + suffixName;
    File filepath = new File(path, fileName);
    ImgObject imgObject = new ImgObject(hash, path, name, staticConfig.UserMail, "nomal");
    imgService.addImg(imgObject);
    if (!filepath.getParentFile().exists()) {
    filepath.getParentFile().mkdirs();
    }
    File tempFile = new File(path + fileName);
    file.transferTo(tempFile);
    return true;
    } catch (Exception e) {
    return false;
    }
    }
    }
  • 相关阅读:
    C#static
    Sql中CHARINDEX用法
    分分钟用上C#中的委托和事件
    为什么使用抽象类?有什么好处?
    【NOIP】普及组2009 细胞分裂
    【VIJOS】P1512 SuperBrother打鼹鼠
    【NOIP】提高组2014
    @NOIP2018
    @NOIP2018
    @NOIP2018
  • 原文地址:https://www.cnblogs.com/L-L-ALICE/p/14910294.html
Copyright © 2011-2022 走看看