Tag: query parameters

如何从URL中提取参数,无论其编写方式如何?

我想要一种java方法来提取URL的参数,无论这些参数是如何写入其中的,都是常规方式,如( https://www.facebook.com/Doly.mohamed.Smile9?ref=stream&hc_location=stream )这很简单,因为我所要做的就是: URL url = new URL(“www.blabla….etc”); String query = url.getQuery(); try{ String [] params = query.split(“&”); for(int i= 0 ; i < params.length; i++){ String [] split = params[i].split("="); parameters.put(split[0], split[1]); } }catch(NullPointerException ex){} 所以参数值是: key = ref value = stream , key = hc_location value = stream 但是,如果URL具有以其他方式编写的参数,或者如果URL没有像doPost()方式那样在其中写入参数,我该怎么办? 有没有办法从URL获取extraPathInfo而不使用servlet?

如何在JAX-RS中过滤具有无效参数的请求?

“无效”是指不期望的参数。 例如: @Path(“/”) public interface ExampleInterface { @GET @Path(“/example”) public Response test( @QueryParam(“param1”) String param1, @QueryParam(“param2″) String param2 ); } 然后我称之为”…/example?param3=foo”

使用Java的PreparedStatement将数组传递给SQL查询

我使用Java的预处理语句将数组传递给SQL查询时遇到了一些麻烦。 我首先尝试了sourceforge驱动程序,但是当我调用setArray方法时,我会得到AbstractMethodError。 不知道我交换到Microsoft sqlserver驱动程序的解决方案,但现在我完全得到一个不同的错误,即“java.sql.SQLFeatureNotSupportedException:不支持此操作”。 尝试了很多东西来尝试解决这个问题,但似乎没有任何工作可行。 我的Java代码看起来类似于我在这里和互联网上看到的例子,如下所示, PreparedStatement ps = connection.prepareStatement(query); String[] suppliers = {“21″,”2774″,”120563″,”3714″,”59”}; ps.setArray(1, connection.createArrayOf(“text”, suppliers)); ResultSet rs = ps.executeQuery(); 我的SQL查询示例。 真正感兴趣的唯一一条就是前一行,我添加了’?’ 字符,据我所知,它是如何将参数传递给SQL查询。 productsPrices.query = select contract.supplierid as ‘hotelid’ \ , round((rate.s1/money.buy)*euro.sell,0) as “single” \ , round((rate.s2/money.buy)*euro.sell,0) as “double” \ ,service.Name as ‘roomtype’ \ ,stock.alloc – stock.taken as ‘stock.available’ \ , contract.notes as ‘boardType’ […]