简体   繁体   English

Jersey / char []:HTTP错误415:不支持的媒体类型

[英]Jersey / char [] : HTTP error 415 : Unsupported Media Type

I'm using Jersey to expose a REST API. 我正在使用Jersey公开REST API。

I get HTTP error 415 : Unsupported Media Type when I try to send a request to the following entry point : 当我尝试向以下入口点发送请求时,出现HTTP错误415:不支持的媒体类型:

  @POST
  @Path("check")
  @Produces("application/json")
  Response checkPassword(char[] password);

But when I turn my password into String, It works fine : 但是当我将密码转换为String时,它可以正常工作:

  Response checkPassword(String password);

The idea of using a char[] is to apply some good practices as stated here : Why is char[] preferred over String for passwords? 使用char[]的想法是要应用此处所述的一些良好做法: 为什么对于密码而言,char []优于String?

Does anyone knows why I get 415 with char [] ? 有谁知道为什么我用char []得到415?

Regards 问候

Can you please post your POST request? 您能发布您的POST请求吗?

As the message tells it is the mediatype of the request which is not supported. 消息告诉我们,不支持请求的媒体类型。

@Consumes("application/json")

which type of data you expect. 您期望哪种类型的数据。 This could be json (then you normally wrap this into some object, or text/plain or xml or whatever you like but currently the type jersey expects is not matching the transfered type either on request or response. 这可能是json(然后通常将其包装到某个对象,text / plain或xml或任何您喜欢的东西中,但是jersey期望的类型当前在请求或响应时都不匹配所传输的类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM