我要发 String数组直接使用类似:
service....post(ClientResponse.class, new String[]{"one","two","three"} );有一个 的MediaType 可用于检索服务器上的字符串数组?
在我实现我有一个警告提示 的String [] 不是解析为一个具体类型。
In my implementation I have a WARNING saying that String[] is not resolvable to a concrete type.
我怎样才能张贴阵列封装没有到另一个( @XmlRootElement )类?
How can I POST an array without encapsulating it into another (@XmlRootElement) class?
推荐答案请参阅How在泽西REST Web服务返回数组?(不完全是这样,但相关的)。
See How to return Array in Jersey REST webservice? (not exactly this, but related).
JAX-RS(也不泽西)不支持原始类型,包括字符串返回列表。格式不指定,所以你需要将数据封装成的东西,并使用XML / JSON(我会这么做),也可以实现对任何你希望你的化MessageBodyReader /作家(甚至字符串数组)。参见:
JAX-RS (nor Jersey) does not support returning List of primitive types, including String. Format is not specified, so you'll need to encapsulate your data into something and use XML/JSON (I would do that) OR you can implement your MessageBodyReader/Writer for whatever you want (even array of strings). See:
- 化MessageBodyReader
- MessageBodyWriter
- MessageBodyReader
- MessageBodyWriter
编辑:在客户端JSONArray:
edit: JSONArray on client side:
ClientConfig cc = new DefaultClientConfig(); cc.getClasses().add(JSONArrayProvider.App.class); Client c = Client.create(cc); JSONArray array = new JSONArray(); array.put(1); array.put(4); c.addFilter(new LoggingFilter()); c.resource("a.cz").type(MediaType.APPLICATION_JSON_TYPE).post(array);更多推荐
如何发布字符串与新泽西数组
发布评论