Angular 2 个 HTTP POST IE 11 中的错误
Angular 2 HTTPs POST ERROR In IE 11
我正在使用 angular 2 拨打 post 电话。
create() {
let headers = new Headers({ 'Content-Type': 'text/plain' });
let options = new RequestOptions({ headers: headers });
let body = JSON.stringify({message:'[START]});
this.http.post('https://localhost:8888/client/get', body, options)
.map(res => res.json())
.subscribe(
data => console.log(data) ,
err => console.log(err)
);
}
当我使用 http://localhost:8888/client/get
时它工作正常,但是当我尝试使用 https://localhost:8888/client/get
进行 post 调用时我收到以下错误:
其余 Web 服务构建在 spring 引导上。我使用自签名证书通过 https 协议访问本地主机。我按照 this 文章中提供的步骤通过 https 访问本地主机。
请告知如何解决此问题。
我用不同的 URL 测试了同一段代码,它有一个正确的证书可以正常工作。因此很明显问题出在证书上。作为解决方法,我使用了此中提供的建议
http://jonnyreeves.co.uk/2013/making-xhr-request-to-https-domains-with-winjs/.
下面是 angular;
中的解决方法
ngOnInit() {
this.get();
}
get(){
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
this.http.get('https://localhost:8888',options);
}
create() {
let headers = new Headers({ 'Content-Type': 'text/plain' });
let options = new RequestOptions({ headers: headers });
let body = JSON.stringify({message:'[START]});
this.http.post('https://localhost:8888/client/get', body, options)
.map(res => res.json())
.subscribe(
data => console.log(data) ,
err => console.log(err)
);
}
调用get方法后我们可以使用post方法
我正在使用 angular 2 拨打 post 电话。
create() {
let headers = new Headers({ 'Content-Type': 'text/plain' });
let options = new RequestOptions({ headers: headers });
let body = JSON.stringify({message:'[START]});
this.http.post('https://localhost:8888/client/get', body, options)
.map(res => res.json())
.subscribe(
data => console.log(data) ,
err => console.log(err)
);
}
当我使用 http://localhost:8888/client/get
时它工作正常,但是当我尝试使用 https://localhost:8888/client/get
进行 post 调用时我收到以下错误:
其余 Web 服务构建在 spring 引导上。我使用自签名证书通过 https 协议访问本地主机。我按照 this 文章中提供的步骤通过 https 访问本地主机。
请告知如何解决此问题。
我用不同的 URL 测试了同一段代码,它有一个正确的证书可以正常工作。因此很明显问题出在证书上。作为解决方法,我使用了此中提供的建议 http://jonnyreeves.co.uk/2013/making-xhr-request-to-https-domains-with-winjs/.
下面是 angular;
中的解决方法 ngOnInit() {
this.get();
}
get(){
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
this.http.get('https://localhost:8888',options);
}
create() {
let headers = new Headers({ 'Content-Type': 'text/plain' });
let options = new RequestOptions({ headers: headers });
let body = JSON.stringify({message:'[START]});
this.http.post('https://localhost:8888/client/get', body, options)
.map(res => res.json())
.subscribe(
data => console.log(data) ,
err => console.log(err)
);
}
调用get方法后我们可以使用post方法