泽西岛 - @Consumes不约束请求 - IllegalStateException @FormParam

时间:2016-11-10 11:00:17

标签: java spring jax-rs jersey-2.0

我正在使用Jersey,我有@Consume(MediaType.APPLICATION_FORM_URLENCODED)注释的资源。但是,当使用json body(和content-type Application / json)向该端点发出请求时,我看到以下异常:

“当请求实体的内容类型不是application / x-www-form-urlencoded时,会使用@FormParam”

任何人都知道我错过了什么? 或者也许Jersey中验证请求内容类型匹配@Consumes注释的代码在哪里,所以我可以调试它?

P.S。 我正在使用Jersey 2.22.1

异常堆栈跟踪:

[Request]: "\(Constants.GENERAL_ADDRESS_2)\(Constants.API_MODIFYUSER_PROFILE_PHOTO)"
[Response]: <NSHTTPURLResponse: 0x17023c0e0> { URL: "\(Constants.GENERAL_ADDRESS_2)\(Constants.API_MODIFYUSER_PROFILE_PHOTO)" } { status code: 500, headers {
    "Cache-Control" = "no-cache, private";
    Connection = close;
    "Content-Length" = 5545;
    "Content-Type" = "text/html; charset=UTF-8";
    Date = "Thu, 10 Nov 2016 10:49:00 GMT";
    Server = "Apache/2.4.18 (Amazon) OpenSSL/1.0.1k-fips PHP/5.6.21";
    "X-Powered-By" = "PHP/5.6.21";
} }
[Data]: 5545 bytes
[Result]: FAILURE: responseValidationFailed(Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(500))
[Timeline]: Timeline: { "Request Start Time": 500467740.667, "Initial Response Time": 500467740.793, "Request Completed Time": 500467743.733, "Serialization Completed Time": 500467743.733, "Latency": 0.126 secs, "Request Duration": 3.066 secs, "Serialization Duration": 0.000 secs, "Total Duration": 3.066 secs

0 个答案:

没有答案