<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Jianhua, <br>
Which version of resteasy are you using ? <br>
Can you try with resteasy-3.0.19.Final and create entity with
utf-8 character like this ? <br>
Form form = new Form();<br>
form.param("album", "光明随想");<br>
Entity<Form> entity = Entity.entity(form,
MediaType.APPLICATION_FORM_URLENCODED_TYPE.withCharset("utf-8"));<br>
ClientBuilder.newClient().target(youadress).request().post(entity)<br>
<br>
I tested and it works. <br>
<br>
Thanks,<br>
Jim<br>
<br>
On 10/19/2016 10:30 AM, Jianhua Zhang wrote:<br>
</div>
<blockquote
cite="mid:CAP88TatL4agodzxHFhsZfet5L0=j=9TocV4dH794ZapzvDBy+A@mail.gmail.com"
type="cite">
<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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
resteasy-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:resteasy-dev@lists.jboss.org">resteasy-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/resteasy-dev">https://lists.jboss.org/mailman/listinfo/resteasy-dev</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>