SPRINGMVC learn to accept JSON parameters

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.