1.在后台加上配置,在springmvc中添加:
<!--配置跨域请求问题-->
<mvc:cors>
<mvc:mapping path="/**"
allowed-origins="http://127.0.0.1:8080,http://localhost:8080"
allowed-methods="POST,GET, OPTIONS,DELETE,PUT"
allowed-headers="Content-Type,ContentType,Access-Control-Allow-Headers, Authorization, X-Requested-With"
allow-credentials="true"/>
</mvc:cors>
2.在前端使用的是axios,具体参考一下的地址。