I need to send a html form to a springboot application. The Form is manipulated before submitting, so I use an ajax request to submit it manually:
$.ajax({
method: 'POST',
processData: false,
contentType: false,
url: form_submit_url,
data: formData
});
I checked formData to be sure that it contains all form values including files.
The following code works for all form items except files. Inspecting functionRequest shows that file parameters are missing.
@PostMapping(
value = "form_submit_url",
consumes = {
MediaType.MULTIPART_FORM_DATA_VALUE
},
produces = MediaType.APPLICATION_JSON_VALUE
)
@ResponseStatus(HttpStatus.ACCEPTED)
public FunctionResult executeFunction(
final @RequestParam MultiValueMap<String, Object> functionRequest
) {
return null;
}
MultiValueMap is used since received parameters may vary.
Is it possible to reiceive files along with other parameters when using MultiValueMap? Otherwise is there an alternative?