- 前端 用uni.request请求, 无法获取到 登录 时的sessionid, 跨域也做了
uni.request({
url:'http://localhost/rest/tables.shtml',
method:"POST",
async: true,
data:{"restid":124},
xhrFields:{
withCredentials:true
},
crossDomain: true,
header:{
'Content-Type': 'application/x-www-form-urlencoded',
'token' : token,
},
success:function(res){
console.log(res);
}
}) - 后端代码 springmvc,
response.setHeader("Access-Control-Allow-Origin", request.getHeader("origin"));
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "0");
response.setHeader("Access-Control-Allow-Headers", "Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,token");
System.out.println(session.getId());
z***@163.com
解决了么? 我后台也获取不到session信息
2019-09-19 21:38