从前台传数组进入后台使用ajax

从前台传数组进入后台使用ajax

前台代码:
如果Post是string数组或者int数组,则ajax中traditional: true,

如果Post是对象数组,则ajax中traditional: false,否则对象将为空

/ajax中  需要设置 traditional:true,
	       $.ajax({url:"http://localhost:8085/computer/answer",
	       			dataType:'json',
	                type:"post",
	                traditional:true,
	                data:{
	                    answer:answer,
						questionid:questionIds,
						tid:this.test[0].tid
	               },
	               success:function(data){
	               		
	               }

后台代码

@RequestMapping(value="answer")
	public List dealAnswer(String [] answer,Integer [] questionid,Integer tid){
		System.out.println(answer.length);
		System.out.println(questionid.length);
		System.out.println(tid);
		
		return null;
	}

猜你喜欢

转载自blog.csdn.net/weixin_44235109/article/details/99965412