我有一个非常令人沮丧的问题。我把我的服务放在了jersy中,我通过axios调用它。这是我的jersy代码:
@PUT
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response update(@PathParam("id") int id, String jsonRequest) {
return new UpdateController().updateUser(id, jsonRequest);
}
以下是我在前端称呼它的方式:
axios.put(putURL, newUserPreferences)
.then(response => {
.
.
因此,如果我使用avobe put请求调用它,我会收到以下错误代码:
Failed to load puturl...: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3003' is therefore not allowed access. The response had HTTP status code 403.
任何人都可以帮助它为什么会这样吗?