https://github.com/spring-projects/spring-framework/issues/18551 Solved this issue. If param is an instance of KeyDataPair so add it as part, not as parameter.

Comment From: sbrannen

Thanks for the PR!

We'll review it with the intent to include it in 5.3.

In the interim, @rstoyanchev, in https://github.com/spring-projects/spring-framework/issues/18551#issuecomment-453436578 you mentioned that the implementation would need to switch from a MockHttpServletRequest to a MockMultipartHttpServletRequest; whereas, this PR works directly with the existing Part support in the MockHttpServletRequest. Do you still feel that the HtmlUnit support would need the MultipartHttpServletRequest API?

Comment From: rstoyanchev

Creating MockMultipartHttpServletRequest would be closer to simulating an application with a MultipartPartResolver configured. However, for Servlet 3 multipart requests that's not strictly required, and for example MultipartResolutionDelegate will wrap the request with StandardMultipartHttpServletRequest if necessary.

Comment From: kobaeugenea

So can we leave this way of implementation or should I re-implement to use MockMultipartHttpServletRequest?