除了下面的方法之外,还有没有其他方法来验证查询参数值,即是否有一种通过wadl映射到模式的方法。谢谢
@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);发布于 2012-08-02 19:07:55
不幸的是,在当前的JAX-RS版本上对验证的支持有限。但根据draft for JAX-RS 2.0的说法,它在未来将有更好的验证处理。
您可以查看新功能here的示例。
https://stackoverflow.com/questions/11770329
复制相似问题