Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JAX-RS:即使传递了一些不正确的数据类型,@DefaultValue也会被传递吗?_Java_Rest_Jax Rs - Fatal编程技术网

Java JAX-RS:即使传递了一些不正确的数据类型,@DefaultValue也会被传递吗?

Java JAX-RS:即使传递了一些不正确的数据类型,@DefaultValue也会被传递吗?,java,rest,jax-rs,Java,Rest,Jax Rs,我的端点看起来像 @GET @Produces(MediaType.APPLICATION_JSON) public Response getVariables(@QueryParam("_activeonly") @DefaultValue("no") @Nonnull final Active active) { switch (active) { case yes: return Response.o

我的端点看起来像

 @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getVariables(@QueryParam("_activeonly") @DefaultValue("no") @Nonnull final Active active) {
        switch (active) {
            case yes:
                return Response.ok(VariablePresentation.getPresentationVariables(variableManager.getActiveVariables())).build();
            case no:
                return Response.ok(VariablePresentation.getPresentationVariables(variableManager.getVariables())).build();
        }
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    }
其中
处于活动状态

  public enum Active {
        yes,
        no;
    }
我把它测试为

   @Test
    public void testGetAllVariablesUnknownActionFail() throws Exception {
        final ClientRequest clientRequest = new ClientRequest("http://localhost:9090/market/rest/variables?_activeonly=unknown");
        final ClientResponse<String> clientResponse = clientRequest.get(String.class);
        assertEquals(400, clientResponse.getStatus());
    }

这是否意味着如果我传入了一些不正确的值,而这些值没有映射到enum,就会使用
@DefaultValue

我会在端点内输入一个断点或打印一个活动变量,然后查看得到的结果。我原以为序列化会有问题。
: expected:<400> but was:<200>