首页 > 技术文章 > spring MVC 文件上传错误

newlangwen 原文

1.The request sent by the client was syntactically incorrect ()

http://luanxiyuan.iteye.com/blog/1876029

问题原因,无法接收参数。

可能原因,参数名称不正确,获取接收参数为空,如果可能为空,可设置如下

@RequestParam(value = "file", required = false) MultipartFile file

2.如果参数设置正常,后台controller接收到的文件为null

可能没有添加配置

http://bbs.csdn.net/topics/390803763

配置文件中添加:
<!-- id="multipartResolver"必须是multipartResolver -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- maxUploadSize:文件上传的最大值以byte为单位 -->
<property name="maxUploadSize" value="1024000"></property>
</bean>

推荐阅读