开发者社区> 问答> 正文

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

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了.请问,可能是什么原因呢?

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

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

    2020-06-14 17:08:23
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云栖社区特邀专家徐雷Java Spring Boot开发实战系列课程(第20讲):经典面试题与阿里等名企内部招聘求职面试技巧 立即下载
微服务架构模式与原理Spring Cloud开发实战 立即下载
阿里特邀专家徐雷Java Spring Boot开发实战系列课程(第18讲):制作Java Docker镜像与推送到DockerHub和阿里云Docker仓库 立即下载

相关实验场景

更多