标签:getc return map ext category style 服务端 gets boa
客户端:
$scope.saveSelectObj = function(){ var objectArray =new Array(); var obj; for(var i=0;i<$scope.selectObject.length;i++ ) { obj = new Object(); obj.Id = $scope.selectObject[i].value; obj.Name = $scope.selectObject[i].text; objectArray.push(obj); } alert(angular.toJson(objectArray)); }
就是最后一句话 angular.toJson
服务端:
把字符串转换成 JSON对象 JSONObject.parseObject(String)
public ServiceStatus save(String userId, String json) { JSONObject jsonObject = JSONObject.parseObject(json); DashboardWidget widget = new DashboardWidget(); widget.setUserId(userId); widget.setName(jsonObject.getString("name")); widget.setData(jsonObject.getString("data")); widget.setCategoryName(jsonObject.getString("categoryName")); if (StringUtils.isEmpty(widget.getCategoryName())) { widget.setCategoryName("默认分类"); } Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put("widget_name", widget.getName()); paramMap.put("user_id", widget.getUserId()); paramMap.put("category_name", widget.getCategoryName()); if (widgetDao.countExistWidgetName(paramMap) <= 0) { widgetDao.save(widget); return new ServiceStatus(ServiceStatus.Status.Success, "success"); } else { return new ServiceStatus(ServiceStatus.Status.Fail, "Duplicated name"); } }
标签:getc return map ext category style 服务端 gets boa
原文地址:https://www.cnblogs.com/Bruce_H21/p/12598860.html