我是 REST 和球衣的新手。我使用 Jersey 1.17 API 编写了一个简单的 RESTful Web 服务。Web 服务通过 POST 方法接受数据。当我传递具有非 ascii 字符的数据时,它无法正确读取它们。
@POST
@Path("hello")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED + ";charset=UTF-8")
public Response hello(@FormParam("message") String message) {
System.out.println(message);
return Response.status(200).entity("hello" + message).build();
}
当我在参数“消息”中传递具有非 ascii 字符的数据时,它无法正确打印。
curl --data "message=A função, Ãugent" http://localhost:8080/search/hello/
POST 方法打印“A fun??o, ?ugent”