Jersey 集合的多个默认值
Multiple default values for collections with Jersey
我正在使用 Jersey 并想要一个集合,当不添加为查询参数时,默认为包含多个对象的集合。
我基本上想要这个:
@DefaultValue("test1", "test2")
@QueryParam("test")
private Set<MyEnum> test;
到 return 包含枚举 "test1" 和 "test2" 的集合。
我可以毫无问题地使用单个默认值,但我想要多个。文档有点神秘,有可能吗?
根据这个source from Whosebug and the official documentation你只能通过手动检查对象是否为空然后设置默认值来做到这一点
我正在使用 Jersey 并想要一个集合,当不添加为查询参数时,默认为包含多个对象的集合。
我基本上想要这个:
@DefaultValue("test1", "test2")
@QueryParam("test")
private Set<MyEnum> test;
到 return 包含枚举 "test1" 和 "test2" 的集合。 我可以毫无问题地使用单个默认值,但我想要多个。文档有点神秘,有可能吗?
根据这个source from Whosebug and the official documentation你只能通过手动检查对象是否为空然后设置默认值来做到这一点