1.js部分
//跳转到下单页
$scope.orderdown = function () {
//获取域中的list
var breakfast = $scope.breakfast;
var lunch = $scope.lunch;
var dinner = $scope.dinner;
var url = basepath + "createOlderOrder.htm";//跳转的方法
$.ajax({
type : "post",
url : url,
data: {breakfast:JSON.stringify(breakfast) //将list转换成string
, lunch:JSON.stringify(lunch)
,dinner:JSON.stringify(dinner)},
async : false,
error : function() {// 请求失败处理函数
alert("失败");
},
success : function(data){
if(data == 'true'){
alert("1");
}else{
alert("0")
}
}
});
$locati on.path('/orderdown');//跳转的页面
}
2.java部分
/**
* 通过餐点数量,id订餐 创建订单
*/
@RequestMapping(value = "createOlderOrder", method = RequestMethod.POST)
@ResponseBody
@Transactional
public String createOlderOrder(HttpServletRequest request , @RequestParam("breakfast")String breakfast,
@RequestParam("lunch")String lunch,@RequestParam("dinner")String dinner) throws Exception {
// 总价赋空
BigDecimal carteAmount = new BigDecimal(BigInteger.ZERO);