简体   繁体   English

对于大于 150kb 的文件上传请求参数为 null,使用 multipartfile 上传,Spring 3.2,wildfly 9.0.0

[英]request parameters null for file upload greater than 150kb with multipartfile upload, Spring 3.2, wildfly 9.0.0

We upgraded the code from jboss 4 to wildfly 9 and upgraded spring 2.5 to spring 3.0 and everything is working good.我们将代码从 jboss 4 升级到 wildfly 9,并将 spring 2.5 升级到 spring 3.0,一切正常。

While we are uploading files less than 150kb using MultipartFile, it is working fine.虽然我们使用 MultipartFile 上传小于 150kb 的文件,但它工作正常。 but when file size exceeds 150kb all request parameters and multipartfile becomes null.但是当文件大小超过 150kb 时,所有请求参数和 multipartfile 都变为空。

We are using Spring 3.2, java 8, wildfly 9.0我们使用的是 Spring 3.2、java 8、wildfly 9.0

i am attaching my code for your reference我附上我的代码供您参考

Controller控制器

@Controller
@MultipartConfig(fileSizeThreshold=1024*1024*2, // 2MB
maxFileSize=1024*1024*10,      // 10MB
maxRequestSize=1024*1024*50)
public class MyPortFolioController{

@RequestMapping(value = UrlPrefix.consumer+"/myportfolio.htm", method = RequestMethod.POST)
    public ModelAndView uploadFile(@ModelAttribute Portfolio portfolio, BindingResult result, 
            Model model,@RequestParam("file")MultipartFile f,HttpServletRequest request,HttpServletResponse response, HttpSession session

jsp file jsp文件

    <form:form modelAttribute="portfolio" method="POST" id="myuplod" enctype="multipart/form-data" name="portfolioform">

<form:select path="protfolioTypeIdentifier" id="selectType" cssClass="form-control" cssStyle="width:auto;">
                                      <form:option value="0">Select one</form:option>
                                      <form:options items="${portfolioType}"
                                            itemValue="protfolioTypeIdentifier"
                                            itemLabel="portFolioTypeName" />
                                  </form:select>
<input type="file" name="file" class="btn btn-primary" onchange="dwr.util.byId('upportf').style.display='block';"/>
<input  type="submit" value="Upload" class="btn btn-warning" id="upportf" name="Upload" onclick="displayLoaderScreen();"/>

</form:form>

applicationContext.xml应用上下文.xml

<bean id="multipartResolvder" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" >
    <!-- 25 mb max -->
     <property name="maxUploadSize" value="26214400"/>
</bean>

please help请帮忙

Files with size "maxInMemorySize " are stored in memory, otherwise they will be stored in disk directly.大小为“maxInMemorySize”的文件存储在内存中,否则将直接存储在磁盘中。 Default is 10KB (10240 bytes)默认为 10KB(10240 字节)

Add these line in spring.xml Add these line in spring.xml在 spring.xml 中添加这些行 在 spring.xml 中添加这些行

    <!-- mutipart upload configuration -->
    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!-- max upload size in bytes 2MB-->
        <property name="maxUploadSize" value="2097152" />
        <!-- max size of file in memory (in bytes) 2MB -->
        <property name="maxInMemorySize" value="2097152" />
    </bean>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring MultipartFile上传文件位置 - Spring MultipartFile upload file location 上传文件时,Spring REST MultipartFile文件始终为null - Spring REST MultipartFile file is always null when do upload file 在Spring 2.5中使用MultipartFile上传文件中的null值 - null value in file upload by using MultipartFile in spring 2.5 Spring MVC 4 AJAX上传带有额外参数的MultipartFile - Spring MVC 4 AJAX upload MultipartFile with extra parameters Spring 3.0 MultipartFile上传 - Spring 3.0 MultipartFile upload 使用Spring Boot的Spring Rest:将MultipartFile和Json对象作为参数上传 - Spring rest with Spring Boot: Upload MultipartFile and Json object as parameters Spring Cloud Feign MultipartFile上传 - Spring Cloud Feign MultipartFile upload Spring + ExtJS 文件上传所需的 MultipartFile 参数“文件”不存在 - Spring + ExtJS File Upload Required MultipartFile parameter 'file' is not present 使用Spring MultipartFile和谷歌应用引擎上传文件 - upload a file using spring MultipartFile and google app engine 在 Spring Boot 2.1 MultipartFile - 启用 SSL(https)时上传文件时,几乎 50% http 400 bad request error - Got almost 50% http 400 bad request error on Spring Boot 2.1 MultipartFile - file upload when enable SSL(https)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM