vue-resource $http 跨域访问 session失效
设置withCredentials: true 携带cookie
main.js设置
Vue.http.options.withCredentials = true;
或者:withCredentials: true
this.$http.get(url,{ emulateJSON : true,withCredentials: true }).then(res=>{
console.log(res);
});
springMVC 5.0配置
<!-- 跨域访问 -->
<mvc:cors>
<mvc:mapping path="/**"
allow-credentials="true"
allowed-origins="http://localhost:8080"/>
</mvc:cors>
axios 跨域设置:
import axios from 'axios';
axios.defaults.withCredentials=true;
axios.get(url).then(res=>{
console.log(res);
});