• 上传图片


    <form action="add" method="post" enctype="multipart/form-data">
        日期:<input type="date" name="date" value=""><br>
        类型:<select name="t_id">
            <c:forEach items="${types}" var="t">
                <option value="${t.t_id}">${t.type}
            </c:forEach>
        </select>
        <br>
        题目:<input type="text" name="title" onblur="ti()" value="">
        <br>
        图片:<input type="file" name="myfile" value="">
        <br>
        <button>提交</button>
    </form>
    @SuppressWarnings("deprecation")
        @RequestMapping("add")
        public Object add(MultipartFile myfile,HttpServletRequest request,Car car) throws IllegalStateException, IOException {
            String string = UUID.randomUUID().toString();
            String realPath = request.getRealPath("/load/");
            File file = new File(realPath+string);
            myfile.transferTo(file);
            car.setVivo(string);
            service.save(car);
            redisTemplate.opsForValue().set("car", car);
            System.err.println("保存入redis中");
            kafkaTemplate.send("car", "car");
            System.err.println("发送至卡夫卡");
            return "redirect:findAll";
        }
  • 相关阅读:
    poj 最长公共子序列 1458 记忆式搜索
    选择排序
    直接 插入排序
    直接插入排序
    洛谷-P3389-高斯消元
    经济中的哪些概念
    uva-622-dp
    UVA-607-DP
    转转---面试题
    Linux事件驱动IO中select vs epoll
  • 原文地址:https://www.cnblogs.com/liujinqq7/p/12693770.html
Copyright © 2020-2023  润新知