【发布时间】:2018-05-09 06:48:45
【问题描述】:
如何通过传参发出get请求?我试过这个,但得到 404 错误
getOrderbyOrderNo() {
this.orderno = this.cookie_service.get('key');
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('orderno', this.orderno );
let params = new URLSearchParams();
params.append("someParamKey", this.orderno )
return this.http.get('http://localhost:8080/View/orders', { headers: headers, params: params })
}
输出
ERROR
Object { _body: "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot GET /View/orders</pre>\n</body>\n</html>\n", status: 404, ok: false, statusText: "Not Found", headers: {…}, type: 2, url: "http://localhost:8080/View/orders" }
【问题讨论】:
-
你使用的是httpclient还是http?
-
也显示您的服务器端方法...如果它工作正常,然后按照答案中给出的更改
-
这对你有用吗??
标签: angular httprequest