`
wx1569484809
  • 浏览: 63865 次
文章分类
社区版块
存档分类
最新评论

js前端ajax传值list集合

 
阅读更多

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);

转载于:https://my.oschina.net/iovuMi/blog/1575256

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics