<div dir="ltr">hi,<div><br></div><div>I have a interface need post two parameters (long string, cannot use get or path params), so i choose FormParam annotation:</div><div><br></div><div><div> @Path(value="/song/search")</div><div> @POST</div><div> @Consumes("application/x-www-form-urlencoded;charset=utf-8")</div><div> @Produces("application/json;charset=utf-8")</div><div> ServiceResult getSongList(@FormParam("songs") String songsInfoJson, @FormParam("clientid") String clientId);</div><div><br></div><div><br></div><div>and i use reasteasy-client to call this interface, post paramters like below:</div><div><br></div><div><div>songs:[{"album":"Sunshine 光明随想","title":"婚礼场面舞","artist":"金元辉;","id":"fb49e3de456bee952c8c9b3d3d8977c4","fileName":"100455298.mp3","disk":-1,"duration":112431,"sid":-1,"size":1694184,"albumSid":-1,"albumId":-1},{"album":"","title":"幻想即兴曲","id":"934fdf53d47304e30b587cfae7219136","fileName":"73864517.mp3","disk":-1,"duration":376058,"sid":-1,"size":6018215,"albumSid":-1,"albumId":-1},{"album":"","title":"谷粒飞舞","id":"bffdd1bfa0bfedaf7690540221fee91e","fileName":"73891360.mp3","disk":-1,"duration":145658,"sid":-1,"size":2331813,"albumSid":-1,"albumId":-1}]</div><div>clientid:test123</div></div><div><br></div><div>when server side received, the songsInfoJson content changed to like below:</div><div><br></div><div>[{"album":"Sunshine å…‰æ˜Žéš æƒ³","title":"å©šç¤¼åœºé ¢èˆž","artist":"金元辉;","id":"fb49e3de456bee952c8c9b3d3d8977c4","fileName":"100455298.mp3","disk":-1,"duration":112431,"sid":-1,"size":1694184,"albumSid":-1,"albumId":-1},{"album":"","title":"å¹»æƒ³å ³å…´æ›²","id":"934fdf53d47304e30b587cfae7219136","fileName":"73864517.mp3","disk":-1,"duration":376058,"sid":-1,"size":6018215,"albumSid":-1,"albumId":-1},{"album":"","title":"谷粒飞舞","id":"bffdd1bfa0bfedaf7690540221fee91e","fileName":"73891360.mp3","disk":-1,"duration":145658,"sid":-1,"size":2331813,"albumSid":-1,"albumId":-1}]<br></div><div><br></div><div>========================</div><div><br></div><div>i find the problem is the charset is not set in http request header.</div><div><br></div><div><div>org.jboss.resteasy.client.jaxrs.internal.proxy.processors.invocation.FormParamProcessor create the new form entity, for this entity, the media type is hard code as: APPLICATION_FORM_URLENCODED_TYPE = new MediaType("application", "x-www-form-urlencoded"), the consumes annotaion doesn't take effect.</div><div><br></div><div> form = new Form();</div><div> target.getInvocation().setEntity(Entity.form(form));</div></div><div><br></div><div><br></div><div><div>org.jboss.resteasy.client.jaxrs.internal.ClientInvocation</div><div><br></div><div> public void setEntity(Entity entity)</div><div> {</div><div>...</div><div> Object ent = entity.getEntity();</div><div> setEntityObject(ent);</div><div> this.entityAnnotations = entity.getAnnotations();</div><div> Variant v = entity.getVariant();</div><div> </div><div> //header set</div><div> headers.setMediaType(v.getMediaType());</div><div> headers.setLanguage(v.getLanguage());</div><div> headers.header("Content-Encoding", v.getEncoding());</div><div>...</div><div><br></div><div> }</div></div><div><br></div><div><br></div><div>if manual change x-www-form-urlencoded to x-www-form-urlencoded;charset=utf-8, the problem will save.</div><div>is this a bug or anything wrong with me.</div><div><br></div>-- <br><div class="gmail_signature">Jianhua Zhang<br>iFLYTEK<br></div>
</div></div>