Skip to content

ServletRequestDataBinder does not bind MultipartFile with HiddenHttpMethodFilter and Multipart Request [SPR-7795] #12451

@spring-projects-issues

Description

@spring-projects-issues

Paul Sideleau opened SPR-7795 and commented

I have setup a MultipartFilter and HtmlHiddenMethodFilter following the instructions in #11260 and the javadoc.

I have a java bean that has a org.springframework.web.multipart.MultipartFile property. I attempt to bind my bean with the standard @ModelAttribute annotation. The rest of its properties get resolved correctly but the MultipartFile property is set to null.

I believe the issue is that on line 106 of the ServletRequestDataBinder it does an instanceof check: "request instanceof MultipartRequest" which will return false because its the HttpMethodRequestWrapper class from the HtmlHiddenMethodFilter.

However, if I move the property out of my javabean and bind it via a RequestParam annoation, it works correctly.

public ModelAndView uploadFile(@RequestParam("file") MultipartFile file) {
// code
}


Affects: 3.0.4

Issue Links:

Referenced from: commits b3f039a

1 votes, 2 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions