gpt4 book ai didi

java - 如何获得 RESTeasy 方法以正确使用 application/x-www-form-urlencoded 为 UTF-8?

转载 作者:行者123 更新时间:2023-11-29 09:11:01 25 4
gpt4 key购买 nike

我正在使用

curl --data-binary "content=abcdeöäüabcde" http://myserver.com/application/api -H "Content-Type: application/x-www-form-urlencoded; encoding=utf-8"

POST 表单数据到我的网络服务器。

在服务器端我想解码内容:

@POST
@Path("/api")
@Consumes("application/x-www-form-urlencoded")
public void createNote(@FormParam("content") String content){
System.out.println(content);
}

结果是abcde???abcde

有人知道我如何告诉这个方法将表单参数作为 UTF-8 使用吗?

最佳答案

尝试:

byte[] encoded = content.getBytes("UTF-8");

关于java - 如何获得 RESTeasy 方法以正确使用 application/x-www-form-urlencoded 为 UTF-8?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12491023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com