[英]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.