登录请求

login (data)

return axios({
  method: 'post',
  url: userApi.loginUrl(),
  data: data,
  withCredentials: true
}) }

向服务端发送请求出现
图片描述

在服务端pom.xml中添加
<!-- 跨域请求依赖 -->

    <dependency>
        <groupId>com.thetransactioncompany</groupId>
        <artifactId>cors-filter</artifactId>
        <version>2.5</version>
    </dependency>

在服务端web.xml中添加
<!-- cors filter -->

<filter>
    <filter-name>CORS</filter-name>
    <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>

    <init-param>
        <param-name>cors.allowOrigin</param-name>
        <param-value>*</param-value>
    </init-param>
    <async-supported>true</async-supported>
</filter>
<filter-mapping>
    <filter-name>CORS</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

跨域参考文档:http://www.boyunjian.com/java...


KrisXue
141 声望6 粉丝

前端工程师