AJAX
利用jquery
<script> function loadXMLDoc() { var params = {}; params.sellerId = "1111111111111111111111111111111111"; $.ajax({ type: "POST",url: "http://localhost:8080/v1/seller/order/new",data: JSON.stringify(params),contentType: "application/json; charset=utf-8",//此处不能省略 dataType: 'json',success: function (data) { if (data.code != 200) { alert("失败") } else { } },error: function () { alert("numerror"); } }); } function myFunction() { loadXMLDoc(); } </script>
SPRING
/** * 创建订单 */
@RequestMapping(value = "/order/new",method = RequestMethod.POST)
public void newOrder(@RequestBody SellerOrderRequest sellerOrderRequest) {
logger.info("Create new seller order : {}",sellerOrderRequest.getSellerId());
}
public class SellerOrderRequest {
private String sellerId;
public String getSellerId() {
return sellerId;
}
public void setSellerId(String sellerId) {
this.sellerId = sellerId;
}
}