我的客户端应用程序(前端)-Angular 我的服务器端应用程序(后端)-Java JAX-RS(jersy)
从前端到后端调用函数时出现此错误
我的角度服务代码
import { User } from './../model/user';
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
const headeroption = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};
@Injectable({
providedIn: 'root'
})
export class UserService {
constructor(private http: HttpClient) { }
url = 'http://localhost:9090/HealthCare2/services/';
user: Observable<User[]>;
//Testing
test() {
return this.http.get(this.url + 'user/test');
}
我的Java JAX-RS控制器
@Path("/user")
public class UserController {
UserService userService = new UserService();
// Test function
@GET
@Path("/test")
@Produces(MediaType.TEXT_HTML)
public String testing() {
return "Test Function is working";
}
}