Java 飞行前的响应没有HTTP ok状态。

Java 飞行前的响应没有HTTP ok状态。,java,spring,angular,spring-boot,angular6,Java,Spring,Angular,Spring Boot,Angular6,我使用angular 6登录的用户服务是: loginUser(user:any):Observable<any>{ const headers=new HttpHeaders({'Access-Control-Allow-Origin':'*'}); return this.http.post("http://localhost:8080/login",user,{headers:headers}); } saveUser(user:a

我使用angular 6登录的用户服务是:

loginUser(user:any):Observable<any>{
         const headers=new HttpHeaders({'Access-Control-Allow-Origin':'*'});
         return this.http.post("http://localhost:8080/login",user,{headers:headers});
   } 

saveUser(user:any):Observable<any>{
         const headers=new HttpHeaders({'Access-Control-Allow-Origin':'*'});
         return this.http.post("http://localhost:8080/registration",user,{headers:headers});
   }
当我尝试从我的计算机登录并注册这些项目时 但当我使用IP地址(如192.168.1.111:8080/login)从其他计算机访问本地主机时,它显示了第一个错误,如:

Failed to load http://localhost:8080/login: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.1.111:8090' is therefore not allowed access.
Response for preflight does not have HTTP ok status.
然后我在chrome中添加了Allowed cross origin extension,它再次向我显示了错误,如:

Failed to load http://localhost:8080/login: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.1.111:8090' is therefore not allowed access.
Response for preflight does not have HTTP ok status.

感谢您提供了可能有助于解决问题的代码,但通常情况下,如果答案中包含对代码的用途以及解决问题的原因的解释,则会更有帮助。