package com.sincere.student.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; @Controller public class IndexController { @RequestMapping("index") public String index(){ return "index" ; } @ResponseBody @RequestMapping(value = "upload" ,method = RequestMethod.POST) public String upload(@RequestParam("file") MultipartFile file) throws Exception{ return file.getOriginalFilename() ; } }