- //controller配置
- @Controller
- public class ServletFile {
- @RequestMapping("testUpload")
- public String testUpload(@RequestParam("desc") String desc , @RequestParam("file") MultipartFile file) throws IOException{
- InputStream is = file.getInputStream();
- String relname = file.getOriginalFilename();
- OutputStream os = new FileOutputStream("D:\\"+relname);
- byte[] byt = new byte[1024];
- int len = -1;
-
- while((len = is.read(byt)) != -1){
- os.write(byt,0,len);
- }
- os.close();
- is.close();
- return "MyJsp";
- }
- }
|