ajax跨域问题

//Springmvc接口

@RequestMapping(value="/cameraStauts", method=RequestMethod.GET, produces = "text/html;charset=UTF-8")//解决jsonp中文乱码问题

public @ResponseBody String cameraStauts(String callback){

  List<Camera> list = cameraService.findAllCamera();
  String jsonString = JSONObject.toJSONString(list);
  String str=callback+"("+jsonString+")";
  return str;
}

//ajax请求调用

$.getJSON("http://192.168.168.197:8080/video/cameraStauts?callback=?",function(data){

});

原文地址:https://www.cnblogs.com/shaohaixiong/p/5644345.html