标签:24* out load comm set query update 大小 ppi
springmvc.xml
<!-- 上传图片配置实现类 注意:id不能变 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- 上传图片的大小 单位b 5M=1*1024*1024--> <property name="maxUploadSize" value="5000000"></property> </bean>
ItemController
@RequestMapping(value="/updateitem.action") public String updateQueryVo(QueryVo vo,MultipartFile pictureFile) throws Exception { //上传图片的形参与jsp页面的name一致 //保存图片到D:\\upload String name = UUID.randomUUID().toString().replaceAll("-",""); //获取文件扩展名,如jpg String ext = FilenameUtils.getExtension(pictureFile.getOriginalFilename()); pictureFile.transferTo(new File("D:\\upload\\"+name+"."+ext)); vo.getItems().setPic(name + "." + ext); //修改 itemService.updateItemsById(vo.getItems()); System.out.println("这是前方法"+vo.getItems()); return "redirect:/itemEdit.action?id="+vo.getItems().getId(); }
标签:24* out load comm set query update 大小 ppi
原文地址:https://www.cnblogs.com/syj1993/p/9912399.html