gpt4 book ai didi

java - Resteasy(多部分/表单数据): how to read multi value field values to List?

转载 作者:行者123 更新时间:2023-11-30 09:40:42 24 4
gpt4 key购买 nike

我需要一些关于 resteasy 的帮助。我有一个包含多个多值字段的多部分 Web 表单。我对主题参数的请求数据:

------WebKitFormBoundary2sX84QQsaESs9qTv
Content-Disposition: form-data; name="topics"

3569
------WebKitFormBoundary2sX84QQsaESs9qTv
Content-Disposition: form-data; name="topics"

18421
------WebKitFormBoundary2sX84QQsaESs9qTv
Content-Disposition: form-data; name="topics"

9703

如何读取要列出的“主题”参数?这就是我的主题参数属性的注释方式

@FormParam("topics")
private String[] topics;

但我得到一个异常(exception):

Unable to find a MessageBodyReader for media type: text/plain;charset="us-ascii" and class type [Ljava.lang.String;

任何帮助或示例将不胜感激。

亲切的问候

阿曼多

最佳答案

这是您要找的吗?

@PUT
@Path("/someurl")
@Consumes("multipart/form-data")
@Produces("text/plain;charset=UTF-8")
public String someUrl(MultipartFormDataInput form)
{
try {
List<InputPart> l = form.getFormDataMap().get("topics");
String topic1 = l.get(0).getBodyAsString();
String topic2 = l.get(1).getBodyAsString();
String topic3 = l.get(2).getBodyAsString();
// do something with the topics ...
} catch (IOException e) {
e.printStackTrace();
}
return "something went wrong";
}

关于java - Resteasy(多部分/表单数据): how to read multi value field values to List?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9279240/

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