/**
* IndexController
*
*
*/
@Controller
public class IndexController {
private static final String FAR_SERVICE_DIR = "http://192.168.30.39:8080/receive";// 远程服务器接受文件的路由
private static final long yourMaxRequestSize = 10000000;
@RequestMapping("/")
public String index(Model model) throws IOException {
return "/index";
}
@RequestMapping("/upload")
public String upload(HttpServletRequest request) throws Exception {
// 判断enctype属性是否为multipart/form-data
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart)
throw new IllegalArgumentException(
"上传内容不是有效的multipart/form-data类型.");
// Create a factory for disk-based file items
DiskFileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);