开发者社区> 问答> 正文

关于webuploader文件上传的问题?报错

/*
	 * 文件上传
	 *
	 */
	@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



展开
收起
爱吃鱼的程序员 2020-06-09 10:17:02 842 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    后端方法接口要加上produces=MediaType.TEXT_PLAIN_VALUE,而且返回值是String类型,可以参考这篇文章:https://blog.csdn.net/li396864285/article/details/52815822

    2020-06-09 10:17:21
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载