当前位置: 代码迷 >> 综合 >> springMVC如何跨域请求-jsonp
  详细解决方案

springMVC如何跨域请求-jsonp

热度:35   发布时间:2023-12-16 11:40:04.0



前端 


$.getJSON(" http://ip/example/getStudentById?jsoncallback=jsonp1236827957501",function(json){
       
 });





spring MVC端


@RequestMapping(value="getStudentById" ,produces = "text/html;charset=UTF-8")
public String sso(HttpServletRequest request, HttpServletResponse response) {

StringBuilder result = new StringBuilder();
result.append(request.getParameter("jsoncallback")).append('(').append("{}").append(')');
return result.toString();
}
  相关解决方案