本文介绍了新泽西州bean验证ParameterNameProvider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读有关 bean验证的泽西岛文档. ParameterNameProvider示例显示了如何为方法定义参数名称.但是,对于每个显然无法扩展的方法,实现似乎都必须执行此操作.该示例基本上是没有用的.

I was reading the Jersey docs about bean validation. The ParameterNameProvider example shows how to define parameter names for a method. However, the implementation looks like this will have to be done for each and every method which obviously doesn't scale. The example is basically useless as is.

是否有更聪明的方法来做到这一点? Jersey无法从@QueryParam@PathParam批注中推断名称吗?

Is there a smarter way to do this? Couldn't Jersey infer the name from @QueryParam or @PathParam annotations?

推荐答案

在这里查看我的问题的答案.它应该完全按照您想要的去做.

Take a look at the answer in my question here. It should do exactly what you want.

我可以更改属性吗?方法参数的ConstraintValidator中的路径?

如果您复制我的代码并通过调试器运行它,您将看到对于使用它的每种方法,它只会被评估一次.然后,在您的应用正常运行期间,无需再次解析名称.

If you copy my code and run it through a debugger you will see that it is only evaluated once for each method for which it is used. Then during normal running of your app the names will not need to be resolved again.

这篇关于新泽西州bean验证ParameterNameProvider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 22:24