2
我創建了一個Jersey POST API,即將text/plain作爲正文。我已經在本地嘗試了這個API,並且它按預期工作,但是在將它部署到服務器後,我得到415 Unsupported Media Type。具有字符串正文的Jersey POST API在服務器上無法正常工作(但在本地工作)
這是代碼:
@POST
@Path("/dodo")
@Consumes({MediaType.TEXT_PLAIN})
@Produces({MediaType.APPLICATION_JSON})
public Response Dodo(String input){
return Response.status(200).entity(new JerseyDto(input,12)).build();
}
這是錯誤我在日誌中看到:
com.sun.jersey.spi.container.ContainerRequest getEntity
SEVERE: A message body reader for Java class java.lang.String, and Java type class java.lang.String, and MIME media type text/plain was not found.
The registered message body readers compatible with the MIME media type are:
*/* ->
com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
有什麼想法?