本文介绍了服务器415响应码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jetty Web服务器和Jersey进行REST处理.

I am using Jetty web server, and Jersey for REST handling.

我定义了:

@POST
@Path("/sendMessage")
@Consumes ({MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public Response sendMessage(@Context final UriInfo uriInfo)
{
    logger.debug("sendMessage:");
    System.out.println("Received POST!");
    return Response.status(Response.Status.OK).build();

}

但是,当我发送http请求http://localhost:8080/hqsim/sendMessage时,服务器返回了415码.

However, when I send a http request, http://localhost:8080/hqsim/sendMessage, the server returns a 415 code.

这就像不允许通话.如何解决此错误?

It's like the call is not allowed. How can I fix this error?

推荐答案

415表示不支持媒体类型.最可能的情况是您要么在请求中缺少Content-Type标头,要么它是不正确的.您的情况必须是application/xmltext/xml.

415 means that the media type is unsupported.The most likely case is that you are either missing the Content-Type header in your request, or it's incorrect. In your case it must be application/xml or text/xml.

这篇关于服务器415响应码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 13:32