POST JSON请求中的字符编码 [英] Character Encoding in POST JSON Request

查看:118
本文介绍了POST JSON请求中的字符编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向我的应用程序发送POST JSON请求.

I am sending a POST JSON Request to my application.

POST /CharSetTest/Test HTTP/1.1
Host: localhost:8090
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 1637b92b-5896-4765-63c5-d04ad73ea9f1

{
  "SampleRequest": {
    "FullName": "関連当"
  }
}

我的CXF JAXRS使用者定义如下.

My CXF JAXRS Consumer is defined as below.

@POST
@Produces("application/json; charset=UTF-8")
@Consumes("application/json; charset=UTF-8")
public Response testCharSet(@Encoded String jsonBody);

但是我作为POST请求发送的日语字符(关连当)未编码,并导致一些垃圾字符"é¢é£å½äºè"

But the Japanese Character (関連当) that I sent as POST request is not encoded and results in some junk characters "é¢é£å½äºè"

使用SoapUI会导致"?????"字符.

Using SoapUI results in "?????" characters.

此垃圾字符在我点击请求的地方因客户端而异.我如何编码我的POST请求?

This Junk characters differs from client to client from where I hit the request. How Could I encode my POST Request ?

推荐答案

将内容类型设置为:

"application/json;charset=UTF-8" 

在您正在使用的应用程序中发送发布请求时.您可以在该应用程序的URL标题中找到内容类型".

when sending the post request in the application you are using. You can find "content-type" in the Header of the URL in that application.

这篇关于POST JSON请求中的字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆