关于webuploader文件上传的问题

小小喜欢 发布于 2016/09/27 11:03
阅读 1K+
收藏 0
/*
	 * 文件上传
	 *
	 */
	@RequestMapping(value = "upload", method = RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> upload(@RequestParam(value = "file") MultipartFile file, HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		String url = upload;
		HessianProxyFactory factory = new HessianProxyFactory();
		IBigFileService bigfile = null;
		bigfile = (IBigFileService) factory.create(IBigFileService.class, url);
		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

		Map<String, Object> listMap = new HashMap<String, Object>();
		MultipartFile mFile = multipartRequest.getFile("file");// 得到上传的文件
		String bigfileguid = null;
		if (mFile != null) {
			Long change = mFile.getSize();
			System.out.println("*********&&&&&^^^^%%%%%%%%%"+change);
			int KB = (int) (change / 1024);//// 转化为KB;
			int M = (int) (KB / 1024);//// 转化为M;
			if (M > 10) {// 10M大小
				listMap.put("id", bigfileguid);
				listMap.put("flag", "文件上传大小受到限制");
			} else {
				// 得到上传的文件的文件名
				String filename = mFile.getOriginalFilename();
				InputStream inputStream = mFile.getInputStream();
				byte[] bigfiledata = new byte[inputStream.available()];
				bigfileguid = bigfile.saveBigFileInfo(fileSchema, 02, "13000000", filename, "{\"exe\":\"doc\"}".getBytes(),
						"sd");
				while ((inputStream.read(bigfiledata, 0, bigfiledata.length)) != -1) {
					bigfile.saveBigFileData(fileSchema, 1, bigfileguid, bigfiledata);
				}
				inputStream.close();

				if (bigfileguid != null) {
                    System.out.println("***********&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&77777777777777777777"+bigfileguid);
					listMap.put("id", bigfileguid);
					listMap.put("fileName",filename);
					listMap.put("flag", "上传成功");
				}

			}
		}
		System.out.println("111111111111111111112344444455555566666667"+listMap);
		return listMap;
		
	}



框架用的spring mvc 在利用webUploader 实现文件上传时,在谷歌以及ie8以上都是没有问题的,ie8下,在controller中返回时报错,上边是java代码,下边是输出以及报的错误,求大神指教啊
111111111111111111112344444455555566666667{id=913e2285-a997-4a9b-918c-af9fcac8afb0, flag=上传成功, fileName=免费源码网站注册地址.txt}
DEBUG - Resolving exception from handler [public java.util.Map<java.lang.String, java.lang.Object> heb.trainArchives.controller.FileController.upload(org.springframework.web.multipart.MultipartFile,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
DEBUG - Resolving exception from handler [public java.util.Map<java.lang.String, java.lang.Object> heb.trainArchives.controller.FileController.upload(org.springframework.web.multipart.MultipartFile,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
DEBUG - Resolving exception from handler [public java.util.Map<java.lang.String, java.lang.Object> heb.trainArchives.controller.FileController.upload(org.springframework.web.multipart.MultipartFile,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
DEBUG - Null ModelAndView returned to DispatcherServlet with name 'DispatcherServlet': assuming HandlerAdapter completed request handling
DEBUG - Cleaning up multipart file [file] with original filename [免费源码网站注册地址.txt], stored in memory
DEBUG - Successfully completed request



加载中
返回顶部
顶部