网友回复
Hmll表单上传文件
控制器
import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.COOKIE; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; import java.net.http.HttpResponse; import java.util.List; @Controller public class HelloController { @GetMapping("/multiUpload") public String multiUpload() { return "multiUpload"; } @PostMapping("/multiUpload") @ResponseBody public String multiUpload(HttpServletRequest request) { List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("file"); String file...
点击查看剩余70%