run it on the playground运行使用Typescript,HTML和CSS编写的Angular 4应用程序时出错。
这是我的相关代码:
public url: string = "typeahead-component/";
return this.http
.get(this.url)
.subscribe(
response => {
console.log(response);
},
(err: HttpErrorResponse) => {
if (err.error instanceof Error) {
console.log('An error occurred:', err.error.message);
} else {
console.log("entering http get request.");
console.log(this.url);
console.log(err);
}
}
我将Angular 4前端连接到Spring Boot REST API后端代码。这是后端的相关代码:
@GetMapping("typeahead-component/")
public List<String> get() {
System.out.println("Entering getApps call.");
return getApps.get();
}
我正试图通过服务器网页的HTML从服务器获取应用程序列表。
我已经看过类似的Stack Overflow帖子http://localhost:4200/typeahead-component,但我的问题与in-memory-web-api无关。
我也看过这篇文章Angular 2 HTTP GET 404 Not Found for URL,但未能解决问题。
任何帮助将不胜感激!谢谢!