-1

私は JAX-RS 仕様の jersey 実装を使用しており、POST、GET などの各 HTTP 要求タイプを処理する特定のメソッドを記述しています。PUT と DELETE。しかし、これらすべてのリクエストを単一のメソッドで処理する方法を知りたいです。些細な質問かもしれませんが、ご意見をお聞かせください。

4

1 に答える 1

1

First, I do not recommend this as it is smells of NIH and is almost certainly going to lead you to unmaintainable code. That being said, in Java we have the HttpServlet. From that documentation, emphasis mine -

There's almost no reason to override the service method. service handles standard HTTP requests by dispatching them to the handler methods for each HTTP request type (the doXXX methods listed above).

That is precisely what you are asking how to do, so override the service method.

于 2014-04-24T04:43:39.343 に答える