The front end
$(' # submit). Click (function () {
Var book={};
The book. The name=$(' # name). Val ();
The book. The author=$(' # author). Val ();
The book. The category={
Id: $(' # category). Find (' option). Not (the function () {
return ! This. Selected;
}). Data (' id ')
};
Var formData=https://bbs.csdn.net/topics/new formData ();
FormData. Append (' book 'JSON. Stringify (book));
$. Ajax ({
Url: '/happens',
Type: "POST",
Data: formData,
ContentType: false,
ProcessData: false,
Cache: false,
Success: the function (data) {
If (data. Success) {
Alert (' submitted to success! ');
} else {
Alert (' request failure);
}
}
});
The new out a formdata object, and append a String String the book
Problem on the back-end when I was using a request. The getParameter (" book ") found in the name of the value doesn't write wrong don't get the book under the condition of the string
Turns out that the initial formdata is refer to related information does not support using request access to, want to use to get into the content must rely on the relevant jar and configuration
Pox files need to introduce common - fileupload
Spring's configuration file needs the following configuration
One
Above is the application of formdata