No 'Access-Control-Allow-Origin' header is present on the requested resource.
来源:互联网 发布:linux软件仓库 编辑:程序博客网 时间:2024/06/01 22:17
报错: XMLHttpRequest cannot load ** .No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
资源跨域问题,使用CORS即可.
服务器端添加以下代码即可:
/** * Created by soindy on 2017/4/11. */@Componentpublic class SimpleCORSFilter implements Filter { @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); response.setHeader("Access-Control-Allow-Credentials", "true"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, remember-me"); chain.doFilter(req, res); } @Override public void init(FilterConfig filterConfig) { } @Override public void destroy() { }}
0 0
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore no
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '***' is theref
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin
- No 'Access-Control-Allow-Origin' header is present on the requested resource. 报错解决。
- 解决“No 'Access-Control-Allow-Origin' header is present on the requested resource”
- 解决“No 'Access-Control-Allow-Origin' header is present on the requested resource.”
- No 'Access-Control-Allow-Origin' header is present on the requested resource 的解决方法
- “No 'Access-Control-Allow-Origin' header is present on the requested resource”
- 报No 'Access-Control-Allow-Origin' header is present on the requested resource
- 跨域问题:No 'Access-Control-Allow-Origin' header is present on the requested resource.
- jquery ajax No 'Access-Control-Allow-Origin' header is present on the requested resource
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- No 'Access-Control-Allow-Origin' header is present on the requested resource.
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- “No 'Access-Control-Allow-Origin' header is present on the requested resource”
- MySQL 数据库规范--开发篇
- ionic splash在iphone6plus和7plus上的显示问题
- Android之四大组件五大布局
- Java对象转换成XML
- Tomcat启用HTTPS协议配置过程
- No 'Access-Control-Allow-Origin' header is present on the requested resource.
- PDO操作数据库时 报错:未选择数据库
- Java简单实训五
- Java概述
- hpu1306 大数a+b和a-b
- 使用工厂模式、策略模式实现BASE64,MD5,SHA,HMAC,DES各种加密算法
- Adaboost(2)——基于Python的adaboost实例
- 告诉你为什么数据要取对数
- phpStudy+PhpStorm+XDebug配置