【发布时间】:2017-05-03 08:10:10
【问题描述】:
我有带路径参数的 Rest WS
@Path("/myService/{types}")
public Response myFunction(@Context HttpServletRequest request
,@PathParam("types")String[] types)
{
Criteria criteria = session.createCriteria(myObject.class);
criteria.add(Restrictions.in("tranType", types));
List<myObject> lst= (List<myObject>) criteria.list()
}
或者可能有 ArrayList 或 List 的地方 String[]
我正在尝试从浏览器调用此 WS。当我使用数组中的 1 个参数调用它时,它工作正常。 WS 调用就像/myService/type1。
但是当我想用数组中的 2 个或更多参数调用它时,它不起作用。响应是空数组,但它必须返回填充数组。我用/myService/type1,type2 之类的许多参数调用WS,但它不起作用,我也尝试了/myService/{type1,type2} 和/myService/[type1,type2] 和/myService/["type1","type2"] 和/myService/"type1","type2",但不幸的是没有任何效果。你能告诉我我该怎么做吗?
【问题讨论】:
-
以
String接受它然后根据","拆分它的简单方法。 -
@RahulSingh 您可能想在链接之间插入一些空格。
-
@AmitK 谢谢你
-
@GiorgiGoginashvili 我已经发布了带有所需代码的答案,如果它解决了您的问题,请投票并接受它。