Jersey REST GET工作正常,但PUT无效。 所请求的资源不允许使用指定的HTTP方法

问题描述 投票:1回答:1

我已经为此烦恼了几天。 这个小片段可以正常工作(在Tomcat上使用Jersey 2.26-b03)。

@GET
@Path("/{code}")
public Response update(@PathParam("code") String code) {
    System.out.println("!!!!!!!");
    return Response.status(Response.Status.OK).build();
}

curl -i -X GET http://localhost:18270/nyx/rest/servervirtueel/SVM0000
HTTP/1.1 200 OK

接下来是我启用的许多Jersey跟踪功能。 但是,如果我仅将GET更改为PUT(完全相同的方法,只需更改批注):

@PUT
@Path("/{code}")
public Response update(@PathParam("code") String code) {
    System.out.println("!!!!!!!");
    return Response.status(Response.Status.OK).build();
}

curl -i -X PUT http://localhost:18270/nyx/rest/servervirtueel/SVM0000
HTTP/1.1 405 Method Not Allowed

随后是HTML,告诉我“请求的资源不允许使用指定的HTTP方法”。 但是,POST确实可以工作(再次更改注释)。

rest jersey put http-status-code-405
1个回答
0
投票

事实证明,在Tomcat(Catalina)级别上将OWASP方法白名单阀门配置为仅允许GET和POST。 这是一个迄今为止仅持有SOAP服务的Web应用程序。 您不会在web.xml或server.xml中看到此消息,但是在Catalina / localhost / webappname.xml中看到了此消息。

© www.soinside.com 2019 - 2024. All rights reserved.