dropwizard: produce both html and json from the same class
问题 Is there a way to control the output format from the client side? I have a class which @Produces(MediaType.TEXT_HTML) and I want it to produce json when the client requests. I can copy the class verbatim, replacing only the @Path and @Produces annotations, but this looks like a total waste. I wonder if the client could append something like &content-type=application/json to the URL and have my server respond with json instead of html? 回答1: You'll need to annotate the resources as providing