spring mvc 文件上传报错,页面表单已经写上enctype,问题是根本不?报错-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

spring mvc 文件上传报错,页面表单已经写上enctype,问题是根本不?报错

爱吃鱼的程序员 2020-06-14 17:08:04 13
2015-03-25 12:25:18 Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.runda.biz.syscontroller.controller.SysControllerController.save(com.runda.biz.syscontroller.domain.SysController,org.springframework.web.multipart.MultipartHttpServletRequest)]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'sysController' on field 'nameplate': rejected value [org.springframework.web.multipart.commons.CommonsMultipartFile@a06816]; codes [typeMismatch.sysController.nameplate,typeMismatch.nameplate,typeMismatch.java.lang.String,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [sysController.nameplate,nameplate]; arguments []; default message [nameplate]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.commons.CommonsMultipartFile' to required type 'java.lang.String' for property 'nameplate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.web.multipart.commons.CommonsMultipartFile] to required type [java.lang.String] for property 'nameplate': no matching editors or conversion strategy found]
2015-03-25 12:25:18 Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.runda.biz.syscontroller.controller.SysControllerController.save(com.runda.biz.syscontroller.domain.SysController,org.springframework.web.multipart.MultipartHttpServletRequest)]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'sysController' on field 'nameplate': rejected value [org.springframework.web.multipart.commons.CommonsMultipartFile@a06816]; codes [typeMismatch.sysController.nameplate,typeMismatch.nameplate,typeMismatch.java.lang.String,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [sysController.nameplate,nameplate]; arguments []; default message [nameplate]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.commons.CommonsMultipartFile' to required type 'java.lang.String' for property 'nameplate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.web.multipart.commons.CommonsMultipartFile] to required type [java.lang.String] for property 'nameplate': no matching editors or conversion strategy found]
2015-03-25 12:25:18 Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.runda.biz.syscontroller.controller.SysControllerController.save(com.runda.biz.syscontroller.domain.SysController,org.springframework.web.multipart.MultipartHttpServletRequest)]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'sysController' on field 'nameplate': rejected value [org.springframework.web.multipart.commons.CommonsMultipartFile@a06816]; codes [typeMismatch.sysController.nameplate,typeMismatch.nameplate,typeMismatch.java.lang.String,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [sysController.nameplate,nameplate]; arguments []; default message [nameplate]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.commons.CommonsMultipartFile' to required type 'java.lang.String' for property 'nameplate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.web.multipart.commons.CommonsMultipartFile] to required type [java.lang.String] for property 'nameplate': no matching editors or conversion strategy found]
2015-03-25 12:25:18 Cleaning up multipart file [nameplate] with original filename [2675057235E34C86B4D53341A718CC42.png], stored at [D:\program files\tomcat6\work\Catalina\localhost\xfjd\upload_6d688c8f_14c4f2d6b2e__8000_00000009.tmp]
2015-03-25 12:25:18 Could not complete request
org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'sysController' on field 'nameplate': rejected value [org.springframework.web.multipart.commons.CommonsMultipartFile@a06816]; codes [typeMismatch.sysController.nameplate,typeMismatch.nameplate,typeMismatch.java.lang.String,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [sysController.nameplate,nameplate]; arguments []; default message [nameplate]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.commons.CommonsMultipartFile' to required type 'java.lang.String' for property 'nameplate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.web.multipart.commons.CommonsMultipartFile] to required type [java.lang.String] for property 'nameplate': no matching editors or conversion strategy found]
	at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:111)
	at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:75)
	at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:156)


页面上已经有enctype="multipart/form-data".之前没有上传文件这个字段时正常提交的,现在加上这个字段后,程序就不进controller了.请问,可能是什么原因呢?

前端开发 Java Spring
分享到
取消 提交回答
全部回答(1)
  • 爱吃鱼的程序员
    2020-06-14 17:08:23

    <!--支持上传文件-->
    <beanid="multipartResolver"
    class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <!--setthemaxuploadsize100MB-->
    <propertyname="maxUploadSize">
    <value>104857600</value>
    </property>
    <propertyname="maxInMemorySize">
    <value>4096</value>
    </property>
    </bean>

    0 0
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题