@RequestMapping(value = "/updateInformation",method = RequestMethod.POST)
@ResponseBody
public Boolean updateInformation(Commodity commodity, HttpServletRequest request)throws Exception {
MultipartFile file = null;
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (isMultipart){
MultipartHttpServletRequest multipartRequest = WebUtils.getNativeRequest(request, MultipartHttpServletRequest.class);
file = multipartRequest.getFile("file");
}
}
commodity是pojo类
出错是的代码是这样的
  @RequestMapping(value = "/updateInformation",method = RequestMethod.POST)
@ResponseBody
public Boolean updateInformation(@RequestParam("file") MultipartFile file,Commodity commodity, HttpServletRequest request)throws Exception {
}

  后台报错为; Required request part 'file' is not present

  页面报错为:  Request method 'GET' not supported

springmvc的MultipartFile参数如果不上传文件报错的问题的更多相关文章

  1. Linux - xshell上传文件报错乱码

    xshell上传文件报错乱码,解决方法 rz -be 回车 下载sz  filename

  2. Azkban上传文件报错installation Failed.Error chunking

    azkaban 上传文件报错Caused by: java.sql.SQLException: The size of BLOB/TEXT data inserted in one transacti ...

  3. Tomcat上传文件报错:returned a response status of 403 Forbidden

    出现这样的错误是没有权限对服务器进行写操作.需要在这个项目所在的tomcat中配置可写操作即可: 在tomcat的web.xml添加下面代码: <init-param><param- ...

  4. rz上传文件报错:rpm Read Signature failed: sigh blob(1268): BAD, read returned 0

    上传文件报错: [root@www localdisk]# rpm -ivh cobbler* error: cobbler-2.8.4-4.el7.x86_64.rpm: rpm  Read  Si ...

  5. SecureCRT sftp上传文件报错:put: failed to upload xxx 拒绝访问

    1.问题 使用sftp上传文件时报错:put: failed to upload xxx 拒绝访问.类似下图所示: 2.原因 造成这个问题的原因可能有两个,一是要上到的那个目录剩余磁盘空间不足,二是打 ...

  6. springmvc上传文件报错org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.multipart.MultipartFile]

    在用springmvc+mybatis进行项目开发时,上传文件抛异常... org.springframework.beans.BeanInstantiationException: Could no ...

  7. Spring使用mutipartFile上传文件报错【Failed to instantiate [org.springframework.web.multipart.MultipartFile]】

    报错场景: 使用SSM框架实现文件上传时报“Failed to instantiate [org.springframework.web.multipart.MultipartFile]”错,控制器源 ...

  8. 云笔记项目- 上传文件报错"java.lang.IllegalStateException: File has been moved - cannot be read again"

    在做文件上传时,当写入上传的文件到文件时,会报错“java.lang.IllegalStateException: File has been moved - cannot be read again ...

  9. fetch上传文件报错的问题(multipart: NextPart: EOF)

    技术栈 后台: gin(golang) 前端: react+antd+dva 问题 前端这边使用fetch发送http请求的时候,后端解析formData报错: multipart: NextPart ...

随机推荐

  1. Spring——多种方式实现依赖注入

    在Spring的XML配置中,只有一种声明bean的方式:使用<bean>元素并指定class属性.Spring会从这里获取必要的信息来创建bean. 但是,在XML中声明DI时,会有多种 ...

  2. intellij idea http proxy config

    # custom IntelliJ IDEA properties #http proxy -DproxySet=true -Dhttp.proxyHost=127.0.0.1 -Dhttp.prox ...

  3. JavaWeb_(Hibernate框架)Hibernate配置文件hibernate.cfg.xml

    hibernate.cfg.xml配置文件——链接数据库 hibernate.cfg.xml一定要配置在/src文件目录下 --数据库驱动,url,用户名,密码 --方言org.hibernate.d ...

  4. 8.3 CSS样式

    8.3 CSS样式 参考链接:http://how2j.cn/k/css2/css2-border/249.html 一.CSS有什么作用. 不使用css 给每一个单元格加上背景颜色 .就需要给每一个 ...

  5. TCP最大报文段长度MSS

    最大报文段长度(MSS)表示TCP传往另一端的最大数据库的长度.当一个连接建立时,连接的双方都要通告各自需要接收的MSS选项(MSS选项只能出现在SYN报文段中).如果一方不接收来自另一方的MSS值, ...

  6. Docker关键概念阐述

    要了解Docker需要对其体系结构中的几个关键概念有所了解,主要包括image.container.service.swarm.stack等. 在介绍这几个概念时,会使用到一个测试环境,这个测试环境是 ...

  7. java list对象按照某个属性去重

    /** * 去重 * * @param orderList * @return * @author jqlin */ private static List<ansVo> removeDu ...

  8. 使用SlidingDrawer(滑动式抽屉)实现抽屉效果

    SlidingDrawer隐藏屏外的内容,并允许用户通过handle以显示隐藏内容.它可以垂直或水平滑动,它有俩个View组成,其一是可以拖动的handle,其二是隐藏内容的View.它里面的控件必须 ...

  9. VSCODE开发VUE.JS前端插件

    VUE前端插件.转载自:https://www.cnblogs.com/karthuslorin/p/8577224.html vscode是微软开发的的一款代码编辑器,就如官网上说的一样,vscod ...

  10. Selenium 2自动化测试实战28(断言方法)

    一.断言方法 执行用例的过程中,最终用例是否执行通过,是通过判断测试得到的实例结果与预期结果是否相等决定的.unittest框架的TestCase类提供下面这些方法用于测试结果的判断. -assert ...