[英]Apache cxf Jax Rs encoding issue
I am using jaxrs with Apache cxf . 我在Apache cxf中使用jaxrs。 Below is the xml config
下面是xml配置
<jaxrs:server id="accountrs" address="/rservice">
<jaxrs:serviceBeans>
<ref bean="accountService"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean='jsonProvider' />
</jaxrs:providers>
</jaxrs:server>
For some of my post methods i see that that the double byte charectors are getting distorted and appearing as garbled charectors and getting stored in the database . 对于我的一些发布方法,我看到双字节字符正变得失真,并显示为乱码,并存储在数据库中。
I am reading the json body as string and not as any bean in my service implementation method . 我在服务实现方法中将json正文读取为字符串而不是任何bean。 Below is the sample
下面是示例
@POST
@Path("/accounts/")
public Account getAccount(String jsonBody) {
//Business code goes here
}
I am stuck with this for a while now . 我现在坚持了一段时间。 Can some one help
可以帮个忙吗
Try adding @Consumes("application/json;charset=utf-8") to your getAccount resource. 尝试将@Consumes(“ application / json; charset = utf-8”)添加到您的getAccount资源。 You may also need to specify a @Produces annotation too with a content type and a charset.
您可能还需要使用内容类型和字符集指定@Produces批注。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.