angular springboot跨域访问
来源:互联网 发布:linux ip地址映射 编辑:程序博客网 时间:2024/06/08 11:31
前端使用angular访问http://localhost:8080/people获取数据
控制台显示
XMLHttpRequest cannot load http://localhost:8080/people. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:4200’ is therefore not allowed access.
解决办法:
添加一个配置类,继承WebMvcConfigurerAdapter
重写addCorsMappings方法
@Configurationpublic class CorsConfiguration extends WebMvcConfigurerAdapter { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") //允许跨域访问的链接 "/**" 表示允许所有链接 .allowedMethods("*"); //允许的http方法(GET,PUT,POST,DELETE...),"*"表示允许所有方法 }}
0 0
- angular springboot跨域访问
- springboot 跨域访问
- springboot实现跨域访问
- angular跨域访问的问题
- SpringBoot配置CORS跨域访问
- Angular作用域继承,原型访问机制
- 【Angular】angular 跨域解决方案详解
- angular post json数据到服务器,跨域访问,多大括号
- angular 使用$http.jsonp进行跨域访问以及修改目标JSON
- Angular最新教程-第七节HTTP get post 设置头部 跨域访问
- springboot-aop访问拦截
- SpringBoot的数据访问
- SpringBoot-访问MySQL数据库
- springboot访问jsp页面
- Springboot配置https访问
- springboot访问jsp页面
- 关于springboot访问页面
- springboot访问html文件
- react-native 填坑之canOverrideExistingModule=true
- 正整数或一位小数或者俩位小数的正则表达式的写法
- Spark的安装方法
- Docker搭建disconf环境,三部曲之一:极速搭建disconf
- matlab基础
- angular springboot跨域访问
- 聊聊技术选型
- Netty入门--AIO
- 开篇
- React-Native 性能优化 个人总结
- Ionic开发实战
- PHP开启OpenSSL
- python flask
- IIS+PHP配置