向前端传list集合变成js中的对象

Controller 里的代码       

List categoryIds =new ArrayList<>();
List caterotyList =promotionThemeVO.getCategoryRelationList();
 categoryIds =CommonUtil.getValueList(caterotyList,"relationId");
request.setAttribute("cIds",JsonUtils.toJson(categoryIds));

页面里承接的代码

var categoryIds =${cIds};
js里的代码

var categoryCache={},editCategoryIdsJ={};;
if(categoryIds && categoryIds.length>0){
   for(var i=0;i<categoryIds.length;i++){
      editCategoryIdsJ[categoryIds[i]]=categoryIds[i];
   }
}

你可能感兴趣的:(向前端传list集合变成js中的对象)