Today, SPRINGMVC uses rest mode to commit asynchronously, and the background accepts JSON characters. Found a lot of problems, feeling and spring3.0 use habits somewhat different. Therefore, 4.0 of asynchronous submissions and methods are recorded.
The front page code is as follows:
<script type= "Text/javascript" >
$ (function () {
$ ("#btn"). Click (function () {
var param = {firstuserid: "Shaomch", Seconduserid: "Ramy", Signid: "005", Signtype: "0005"};
$.ajax ({
Type: "Post",
URL: ".. /wshmanager/mobile/feifangroupintentsign/createsign ",
DataType: "JSON",
Data:param,
Success:function (data) {
}
});
});
});
</script>
Note here that previously passed to the background could be a JSON-type string. You can now pass the JSON object directly.
The background Code controller code is as follows:
/**
* Get the object form to accept JSON
* @param param
* @return
*/
@RequestMapping (value = "Createsign", method = Requestmethod.post)
Public @ResponseBody baseresult createsign (feifangroupintentsignparam param) {
Feifangroupintentsignservice.createsign (param);
return baseresult;
}
/**
* Get an attribute in an object
* @param param
* @return
*/
@RequestMapping (value = "Createsign", method = Requestmethod.post)
Public @ResponseBody Baseresult createsign (String firstuserid) {
Feifangroupintentsignservice.createsign (param);
return baseresult;
}
SPRINGMVC learn to accept JSON parameters