Ajax跨域访问

Posted 侯光辉

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ajax跨域访问相关的知识,希望对你有一定的参考价值。

No ‘Access-Control-Allow-Origin‘ header is present on the requested resource. Origin

 参考https://blog.csdn.net/zhoucheng05_13/article/details/53580683

一、服务器端解决

    @ResponseBody
    @GetMapping("/userSource.json")
    public Object userSource(String search,HttpServletResponse response) {
        System.out.println(search);
        response.setHeader("Access-Control-Allow-Origin", "*");
        return getUserSourceService().findAll();
    }

 

以上是关于Ajax跨域访问的主要内容,如果未能解决你的问题,请参考以下文章