跨域请求

1、把js中的问题转移到后台去做,就不回有跨域问题(即服务器端代理)

2、在请求返回头设置

response.addHeader("Access-Control-Allow-Origin", "*");即可

@RequestMapping(params = "method=test")

public void test(HttpServletRequest request, HttpServletResponse response) {

response.setContentType("application/json");

response.setCharacterEncoding("utf-8");

response.addHeader("Access-Control-Allow-Origin", "*");


你可能感兴趣的:(跨域,js)