但是ajax 访问其他服务器会出现跨域问题,在这里直接给出,博主的解决方案:
错误代码:
XMLHttpRequest cannot load http://localhost:8080/hello/get_users_json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access.解决方法:
响应头中加入:(据说可能造成安全问题)
respons.setHeader("Access-Control-Allow-Origin", "*"); 鼠小 认证博客专家 一个萌汉子 未来的路是黑的,我不知道怎么走,我需要做的就是先走着。https://smallzheng.blog.csdn.net/