In book "Spring in Action" i read , the default content type of a post submission is application/x-www-form-urlencoded and takes the form of name-value pairs separated by ampersands. (I believe these all goes as the body payload of the HTTP POST request.)
I further read, with enctype set to multipart/form-data, each field will be submitted as a distinct part of the POST request and not as just another name-value pair.
Q1> I don't get this line. I am from a REST background and will want to understand what in content of the HTTP POST request has changed ?
The server side code
@RequestMapping(method=RequestMethod.POST)
public String addSpitterFromForm(@Valid Spitter spitter,
BindingResult bindingResult,
@RequestParam(value="image", required=false)
Accept file upload
 MultipartFile image) {
if(bindingResult.hasErrors()) {
return "spitters/edit";
}
spitterService.saveSpitter(spitter);
try {
if(!image.isEmpty()) {
validateImage(image);
Validate image
 saveImage(spitter.getId() + ".jpg", image); //
}
} catch (ImageUploadException e) {
bindingResult.reject(e.getMessage());
return "spitters/edit";
}
return "redirect:/spitters/" + spitter.getUsername();
}
The client side code
<sf:form method="POST"
modelAttribute="spitter"
enctype="multipart/form-data">
//other stuff
<tr>
<th><sf:label path="fullName">Full name:</sf:label></th>
<td><sf:input path="fullName" size="15" /><br/>
<sf:errors path="fullName" cssClass="error" />
</td>
</tr><tr>
<th><label for="image">Profile image:</label></th>
<td><input name="image" type="file"/>
</tr>
//other stuff
</sf:form>
From the code I am tempted to think that only the input type="file" is sent in a new way. Rest all are sent as key-value pairs. I think the book is also saying the same "When the form is submitted, it’ll be posted as a multipart form where one of the parts contains the image file’s binary data. "
Q2> If what i am thinking is correct, how does client know which input types to send as key-value pairs and whom to send individually?