from表单提交数组

页面代码:

function submitForm(){
	var categoryArray = new Array();
	var $ss = $("select[name=industryId]");
	$.each($ss,function (i, field){
		categoryArray.push(Number($(field).val()));
	})
	//console.log(categoryArray);
	$("#article-form input[name='categoryArray']").val(categoryArray);
	
	var params = {};
	params.categoryArray = categoryArray;
	params.id = $("#article-form input[name='id']").val();
	params.title = $("#article-form input[name='title']").val();
	params.bigCoverImg = $("#article-form input[name='bigCoverImg']").val();
	params.smallCoverImg = $("#article-form input[name='smallCoverImg']").val();
	params.link = $("#article-form input[name='link']").val();
	
	$.getJSON("${ctx}/operate/pushArticle/save", params, function(result){
		if(!result.success) {
			alert(result.message);
			return;
		}
	});
	
}

 后台接收

@RequestMapping(value = "/operate/pushArticle/save")
    @ResponseBody
    public Map<String, Object> savePushArticle(@ModelAttribute OmArticleManageDto dto, HttpServletRequest request,
                    @RequestParam(value = "categoryArray[]", required = false) Integer[] categoryArray) {
        Map<String, Object> result = new HashMap<String, Object>();
        result = genSuccess();

     List<Integer> idList = Arrays.asList(categoryArray);     //业务逻辑 return result; }

 

posted @ 2016-12-16 09:42  乱码出黑客  阅读(1715)  评论(0编辑  收藏  举报