更新时间:2023-09-02 10:45:52
我在addCorsMappings()方法中错误地编写了*而不是/**
I have mistakenly written * instead of /** in addCorsMappings() method
现在方法看起来像
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
.allowedHeaders("*")
.allowedOrigins("http://localhost:4200","http://localhost:8080");
WebMvcConfigurer.super.addCorsMappings(registry);
}
此外,此后Angular客户端无法获取响应,并为空 在响应中,所以我将其修改为
Also, After that Angular client wasn't able to grab the response and was getting null in the response so I modifed it as
submitData(credential){
credential = JSON.stringify(credential);
return this._http.post("http://localhost:8080/login",credential,{observe: 'response'});
}
现在我正在获得Http响应.
Now I am getting Http response.