账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    springmvc处理图片上传时使用MultipartFile 接收为null。
    29
    0

    1.使用富文本编辑器上传图片,在controller中使用MultipartFile接收为null。debug发现,request经过dispatcherServlet是有值的。而且可以正常映射到方法中去。
    2.springmvc中的配置:

    
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!-- 设定默认编码 -->
        <property name="defaultEncoding" value="UTF-8"></property>
        <!-- 设定文件上传的最大值5MB,5*1024*1024 -->
        <property name="maxUploadSize" value="5242880"></property>
    </bean>
    

    3.DEBUG信息:
    DEBUG [http-bio-90-exec-10] - DispatcherServlet with name 'web' processing GET request for [/js/kindeditor-4.1.10/lang/zh_CN.js]
    DEBUG [http-bio-90-exec-10] - Looking up handler method for path /js/kindeditor-4.1.10/lang/zh_CN.js
    DEBUG [http-bio-90-exec-10] - Did not find handler method for [/js/kindeditor-4.1.10/lang/zh_CN.js]
    DEBUG [http-bio-90-exec-10] - Matching patterns for request [/js/kindeditor-4.1.10/lang/zh_CN.js] are [/js/**]
    DEBUG [http-bio-90-exec-10] - URI Template variables for request [/js/kindeditor-4.1.10/lang/zh_CN.js] are {}
    DEBUG [http-bio-90-exec-10] - Mapping [/js/kindeditor-4.1.10/lang/zh_CN.js] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/js/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@105fda6b]]] and 1 interceptor
    DEBUG [http-bio-90-exec-10] - Last-Modified value for [/js/kindeditor-4.1.10/lang/zh_CN.js] is: -1
    DEBUG [http-bio-90-exec-10] - Null ModelAndView returned to DispatcherServlet with name 'web': assuming HandlerAdapter completed request handling
    DEBUG [http-bio-90-exec-10] - Successfully completed request
    DEBUG [http-bio-90-exec-10] - DispatcherServlet with name 'web' processing GET request for [/js/kindeditor-4.1.10/plugins/multiimage/images/swfupload.swf]
    DEBUG [http-bio-90-exec-10] - Looking up handler method for path /js/kindeditor-4.1.10/plugins/multiimage/images/swfupload.swf
    DEBUG [http-bio-90-exec-10] - Did not find handler method for [/js/kindeditor-4.1.10/plugins/multiimage/images/swfupload.swf]
    DEBUG [http-bio-90-exec-10] - Matching patterns for request [/js/kindeditor-4.1.10/plugins/multiimage/images/swfupload.swf] are [/js/**]
    DEBUG [http-bio-90-exec-10] - URI Template variables for request [/js/kindeditor-4.1.10/plugins/multiimage/images/swfupload.swf] are {}
    DEBUG [http-bio-90-exec-10] - Mapping [/js/kindeditor-4.1.10/plugins/multiimage/images/swfupload.swf] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/js/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@105fda6b]]] and 1 interceptor
    DEBUG [http-bio-90-exec-10] - Last-Modified value for [/js/kindeditor-4.1.10/plugins/multiimage/images/swfupload.swf] is: -1
    DEBUG [http-bio-90-exec-10] - Null ModelAndView returned to DispatcherServlet with name 'web': assuming HandlerAdapter completed request handling
    DEBUG [http-bio-90-exec-10] - Successfully completed request
    DEBUG [http-bio-90-exec-10] - DispatcherServlet with name 'web' processing POST request for [/pic/upload]
    DEBUG [http-bio-90-exec-10] - Found multipart file [uploadFile] of size 345594 bytes with original filename [natalie.png], stored at [D:ideaWorkspace2e3mallwebtargettomcatworkTomcatlocalhost_upload_605390ea_b9db_44ee_9bf4_b426b27db686_00000001.tmp]
    DEBUG [http-bio-90-exec-10] - Looking up handler method for path /pic/upload
    DEBUG [http-bio-90-exec-10] - Returning handler method [public java.util.Map cn.e3mall.controller.PictureController.fileUpload(org.springframework.web.multipart.MultipartFile)]
    DEBUG [http-bio-90-exec-10] - Returning cached instance of singleton bean 'pictureController'
    DEBUG [http-bio-90-exec-10] - Skip CORS processing, request is a same-origin one

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    网站公告
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部