@QueryParam正则表达式 [英] @QueryParam regex expression
本文介绍了@QueryParam正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Jersey for Rest并具有接受@QueryParam.
I am using Jersey for Rest and have a method that accepts @QueryParam.
但是,用户可以这样发送@QueryParam.
:
However, the users may send @QueryParam.
like this:
contractName#
,其中#
是0-155之间的数字.
contractName#
where #
is a number from 0-155.
如何在QueryParam中定义它(如正则表达式)?
How can I define it in QueryParam (like regex expression)?
推荐答案
您无法指定正则表达式.但是,您可以定义一个自定义Java类型来表示该查询参数,并实现您自己从String到该类型的转换-请参见
You can't specify the regexp. However, you can define a custom Java type to represent that query param and implement your own conversion from String to that type - see http://jersey.java.net/nonav/documentation/latest/jax-rs.html#d4e255 (example 2.15).
这篇关于@QueryParam正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文