跨域问题(vscode和idea)
在查询数据的时候报这个错误,就是因为没有解决跨域问题
1.在html中添加:
<meta http-equiv="Access-Control-Allow-Origin" content="*">
链接: 参考资料.
在后台的springMvc.xml文件中添加:
<!-- 接口跨域配置 -->
<mvc:cors>
<!-- allowed-methods="*" --> <!-- 表示所有请求都有效 -->
<mvc:mapping path="/**" allowed-origins="*"
allowed-methods="POST, GET, OPTIONS, DELETE, PUT"
allowed-headers="Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
allow-credentials="true" />
</mvc:cors>