[英]How can I get a RESTeasy method to consume application/x-www-form-urlencoded as UTF-8 correctly?
I am using 我在用
curl --data-binary "content=abcdeöäüabcde" http://myserver.com/application/api -H "Content-Type: application/x-www-form-urlencoded; encoding=utf-8"
to POST
form data to my web server. 对
POST
表单数据到我的Web服务器。
On server side I want to decode the content: 在服务器端,我想解码内容:
@POST
@Path("/api")
@Consumes("application/x-www-form-urlencoded")
public void createNote(@FormParam("content") String content){
System.out.println(content);
}
The result is abcde???abcde
结果是
abcde???abcde
Does anybody know how I can tell this method to consume the form parameters as UTF-8? 有人知道我如何告诉该方法将表单参数作为UTF-8使用吗?
尝试:
byte[] encoded = content.getBytes("UTF-8");
It seems that cURL isn't able to process UTF-8 encoded Strings in POST requests at all. 似乎cURL根本无法处理POST请求中的UTF-8编码的字符串。 Converting the string to
latin1
fixed my problem. 将字符串转换为
latin1
解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.