cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Why is the returned value of posted MultipartFile always null?

former_member863295
Discoverer
0 Likes
2,740
<br>

When submitting the html form, all the values from input tags are binded to the properties of my Helper class, which I POST to the storefront controller as an enctype="multipart/form-data". In controller I have access to ALL the property values and I can proccess them, except for the MultipartFile property which has the value of null. I also tried with MediaType but returned value was also null. What do I do wrong? In which file should I append MultipartResolver bean if I am working in storefront extension?

P.S. I alo tried another way which is to POST a loaded file as a MultipartFile directly to the Controller, but I allways got an error "required request part 'file' is not present". But it is, isn't it?

controller2.png

Most interesting part is that I also created a testing Spring project (not Hybris) in which I did everythig exactly the same way and it works perfectly. I see that other guys have similar problems. What do we do wrong?

Accepted Solutions (1)

Accepted Solutions (1)

samuelyang
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Gorazd,

Did you add the multipartResolver bean to the web application context spring xml file like this? Otherwise multipart requests are not allowed.

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="${cmswebservices.multipartresolver.upload.maxsize}" />
<property name="maxInMemorySize" value="${cmswebservices.multipartresolver.memory.maxsize}" />
</bean>

Answers (1)

Answers (1)

former_member863295
Discoverer
0 Likes

Hi Samuel

In web-application-spring.xml file have I uncluded this part
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="209715200" />
<property name="maxInMemorySize" value="10485760" />
</bean>