Jersey REST GET 正在工作,但 PUT 没有。请求的资源不允许使用指定的 HTTP 方法
Jersey REST GET is working but PUT not. The specified HTTP method is not allowed for the requested resource
几天来我一直在为这个问题伤脑筋。这个小片段工作正常(在 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告诉我那个"The specified HTTP method is not allowed for the requested resource"。但是,POST 确实有效(再次更改注释)。
事实证明,OWASP 方法白名单阀在 Tomcat (Catalina) 级别配置为仅允许 GET 和 POST;到目前为止,这是一个仅包含 SOAP 服务的 Web 应用程序。您在 web.xml 或 server.xml 中看不到它,但它在 Catalina/localhost/webappname.xml.
中
几天来我一直在为这个问题伤脑筋。这个小片段工作正常(在 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告诉我那个"The specified HTTP method is not allowed for the requested resource"。但是,POST 确实有效(再次更改注释)。
事实证明,OWASP 方法白名单阀在 Tomcat (Catalina) 级别配置为仅允许 GET 和 POST;到目前为止,这是一个仅包含 SOAP 服务的 Web 应用程序。您在 web.xml 或 server.xml 中看不到它,但它在 Catalina/localhost/webappname.xml.
中