【发布时间】:2016-07-24 05:00:51
【问题描述】:
我通过 REST google api 使用 Content-Type: application/x-www-form-urlencoded 发送 POST。
------WebKitFormBoundary
Content-Disposition: form-data; name="model"
Content-type: application/json
{
"placeId":2,
"reportDate":"2016-03-10T05:00:00.000Z",
"form":{
"apply" :"NO",
"microbasin": {
"id": 1,
"name": "Caño Rubiales"
}
}
}
------WebKitFormBoundary--
在我的消费方式中:
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response create (@Context UriInfo uriInfo,
@Context HttpServletRequest req,
MultipartFormDataInput input) throws IOException
{
List<InputPart> l = input.getFormDataMap().get("model");
String str = new String (l.get(0).getBodyAsString().getBytes("iso-8859-1"), "UTF-8");
System.out.println(str);
InputStream file = input.getFormDataPart("file", new GenericType<InputStream>() {});
return null;
}
所以Caño 的接收符号是Caýýo。我尝试了很多选项,所有编码类型,但没有成功。有人可以帮我吗,或者给我一些建议,告诉我如何用正确的符号以一种方法接受文件和 json。
【问题讨论】:
-
检查this。自从我使用 JBOSS 已经有一段时间了,但我记得必须在配置文件中为葡萄牙语字符配置一些东西。
-
我昨天试过了,还是不行。
-
试试下面的
@Consumes(MediaType.MULTIPART_FORM_DATA + ";charset=utf-8") -
没有我的朋友:415:不支持的媒体类型。
-
我不知道 RestEasy,所以我会让其他有经验的人为你解答。如果是春天,我可以帮助你。
标签: java json rest jboss resteasy