Advertisement

Required request part 'editormd-image-file' is not present.

阅读量:

缺失必要请求部分错误

我采用SSM框架构建了一个博客系统,在使用editormd实现图片上传功能时遇到了一些问题:

后端提示错误信息为Required request part 'editormd-image-file' is not present

前端则出现cannot parse json...的错误提示,具体错误内容已无法回忆,但大致是无法将某个对象转换为JSON格式。

在此不再赘述,直接提供解决办法。

在SpringMVC中处理MultipartFile时,需要对两个位置进行配置:

在SpringMVC的配置文件中添加如下内容:

复制代码
    <!--dispatcherServlet-servlet.xml -->
    
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <!-- 文件上传的最大值-->
    <property name="maxUploadSize" value="10485760"></property>
    <!-- 文件上传时写入内存的最大值,默认为10240 -->
    <property name="maxInMemo

全部评论 (0)

还没有任何评论哟~