spring mvc上傳圖片

@RequestMapping(value="/save")
    @ResponseBody
    public String save(HttpServletRequest request,HttpServletResponse response,a aaa,@RequestParam(value="file") MultipartFile file) throws Exception {
        InputStream stream=file.getInputStream();
        FileOutputStream outputStream=new FileOutputStream("/upload/upload_file/test.jpg");
        int byteCount = 0;
        byte[] bytes = new byte[1024];
        while ((byteCount = stream.read(bytes)) != -1){
            outputStream.write(bytes, 0, byteCount);
        }
        outputStream.close();
        stream.close();  
        bbb.save(aaa);
        return "ok";
    }app

相關文章
相關標籤/搜索