验证queryparam值jersey [英] Validating queryparam values jersey
本文介绍了验证queryparam值jersey的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
除了以下方法之外还有其他任何方法来验证查询参数值,即是否有通过wadl映射到模式的Jersey方法。谢谢
Are there any other ways besides the one below to validate query parameter values i.e. is there a Jersey way to this by mapping to a schema via a wadl. Thank you
@Path("smooth")
@GET
public Response smooth(
@DefaultValue("blue") @QueryParam("min-color") ColorParam minColor,
public class ColorParam extends Color {
public ColorParam(String s) {
super(getRGB(s));
}
private static int getRGB(String s) {
if (s.charAt(0) == '#') {
try {
Color c = Color.decode("0x" + s.substring(1));
return c.getRGB();
} catch (NumberFormatException e) {
throw new WebApplicationException(400);
推荐答案
不幸的是,对当前JAX-RS版本的验证支持有限。但根据 JAX-RS草案2.0 ,它将来会有更好的验证处理。
Unfortunately, there is limited support for validation on current JAX-RS version. But according to the draft for JAX-RS 2.0, it will have much better validation handling in the future.
你可以看到一个新功能的例子这里。
You can see an example of the new features here.
这篇关于验证queryparam值jersey的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文