标签:stack ima art rac print out test ati not
package com.weixiu.jingwei.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; /** * @Author: 张学涛 * @Date: 2020-05-28 17:46 * @Version 1.0 */ @Controller public class ImageTestWebchatController { @RequestMapping(value = "/weChat/uploadImage", method = { RequestMethod.POST,RequestMethod.GET}) public ModelAndView uploadImage(HttpServletRequest request, HttpServletResponse response) throws IOException { System.out.println("进入get方法!"); MultipartHttpServletRequest req =(MultipartHttpServletRequest)request; MultipartFile multipartFile = req.getFile("file"); String realPath = "F:/image"; try { File dir = new File(realPath); if (!dir.exists()) { dir.mkdir(); } File file = new File(realPath,"aaa.jpg"); multipartFile.transferTo(file); } catch (IOException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } return null; } }
标签:stack ima art rac print out test ati not
原文地址:https://www.cnblogs.com/zhangxuetao/p/12985471.html