1. 导入包:
jackson-core-2.7.4.jar
jackson-databind-2.7.4.jar
jackson-annotations-2.7.4.jar
2. 添加@ResponseBody:
@ResponseBody//自动转换位json对象可以(返回任何类型)
public List< Object > method(){
return null;
}
3. jquery遍历json
//ajax回调函数中用each遍历
success:function(data){
$.each(data,function(index,obj){
alert(obj.key);//或obj["key"]
/*
//遍历json对象
for(var key in obj){
// alert(key+":"+obj[key]);
}
*/
}
}