JS object that array looks like I understand http://blog.csdn.net/baicp3/article/details/12752255 this article
We instruct the sample rods
Data3 a JS object. Will Java contemporary code is received into an entity with the JS object inside the field corresponding.
var data3 = {
"Sign": "0",
"Remarks": "DDDDD",
"Firstkey": "1",
"Firstvalue": "1",
"Eachkey": "1",
"Eachvalue": "1"
} ;
$.ajax ({
URL: '.. /freight/creatfreight.html ',
Type: "POST",
DataType: "JSON",
ContentType: ' Application/json;charset=utf-8 ',
Data:JSON.stringify (DATA3),//Convert to JSON string assumption does not go, Java code is not getting the value
Success:function (data) {
Alert ("CCC");
},
Error:function (e) {
Alert ("Err");
}
});
Let's look at the Java code
@RequestMapping (value = "/creatfreight")
Public @ResponseBody String Creatfreighttempl (
@RequestBody freightdetailentity fd,httpservletrequest Request,
Model model) throws Exception {
The point here is @requestbody this annotation, I have in the previous development very few contact
}
This is the value of the object in JS. The line is passed to the freightdetailentity entity.
2. Let's see SPRNGMVC receives the Array object in JS.
See for example with on the clear.
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvymfpy3az/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/center ">
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvymfpy3az/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/center ">
You should look at the diagram to see how to receive the array object in JS.
3. Multiple variables share a method in the controller in the SPRINGMVC.
@RequestMapping (value = "/{groupcode}", method = Requestmethod.get)
public string view (model, @PathVariable ("Groupcode") string Groupcode) {
Model.addattribute ("Groupcode", Groupcode);
Return "";
}
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Springmvc receiving object Drip Irrigation summary