1.web.xml joins the following nodes, and must be placed in the first filter
<!--all files in the directory can be cross-domain begin -<Filter> <Filter-name>Corsfilter</Filter-name> <Filter-class>Org.apache.catalina.filters.CorsFilter</Filter-class></Filter><filter-mapping> <Filter-name>Corsfilter</Filter-name> <Url-pattern>/*</Url-pattern></filter-mapping>
2.ajax Adding parameters
Native Ajax Request Mode:
var xhr = new XMLHttpRequest (); Xhr.open ("POST", "http://xxxx.com/demo/b/index.php", true); Xhr.withcredentials = true; Support for cross-domain send Cookiesxhr.send ();
The Ajax Post method request for jquery:
$.ajax ({
Type: "POST", URL: "Http://xxx.com/api/test", dataType: ' Jsonp ', xhrfields: { withcredentials:true }, crossdomain:true,
Success:function () {
},
Error:function () {
}
})
Each of the two parameters must be added:
Xhrfields: {withcredentials:true}, Crossdomain:true,
Another problem:
JS cross-Domain call, IFRAME sub-page cross-domain Tuning parent page JS method
Set document.domain = ' abc.com ' on the child page and parent page;//local use Locahost
Java Ajax cross-domain request cookie cannot be brought on a workaround