I hope that by setting up the ajax request, the ajax request can carry the cookie information. I will add
as I said online. beforeSend: function(xhr) {
xhr.withCredentials = true;
}
refer to https://www.cnblogs.com/hello.; there is no way to succeed. Here is my code. I hope friends who have experience in this field can kindly offer some help.
js
$.ajax({
url: URL_MANAGER+"/increase-logintime",
type:"GET",
dataType:"json",
timeout : 30000,
async:false,
beforeSend: function(xhr) {
xhr.withCredentials = true;
},
crossDomain: true,
success:function(data){
_data = data;
},
error:function(XMLHttpRequest, textStatus, errorThrown){
}
})
spring mvc xml configuration
<mvc:cors>
<mvc:mapping path="/**" allowed-origins="http://www.shanhuhaitao.com"
allowed-methods="POST, GET, OPTIONS, DELETE, PUT"
allowed-headers="Content-Type, Access-Control-Allow-Headers,Access-Control-Allow-Origin, Authorization, X-Requested-With,Access-Control-Allow-Credentials"
allow-credentials="true" />
</mvc:cors>
request information
**General**
Request URL: http://localhost:8080/manager/increase-logintime
Request Method: GET
Status Code: 200 OK
Remote Address: [::1]:8080
Referrer Policy: no-referrer-when-downgrade
**response headers**
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://www.shanhuhaitao.com
Content-Type: application/json;charset=UTF-8
Date: Tue, 24 Apr 2018 01:53:28 GMT
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Vary: Origin
**request headers**
Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Connection: keep-alive
Host: localhost:8080
Origin: http://www.shanhuhaitao.com
Referer: http://www.shanhuhaitao.com/spec-manage.html
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
I really can"t find out what went wrong. I hope you seniors can provide some help or clues to solve the problem. Thank you very much