Jersey 中抛出 should not consume any form parameter. exception

简介: 1 在jersey中的代码如下: @GET @Path("getCarInsuranceList") @Produces(MediaType.

1 在jersey中的代码如下:

    
    @GET
    @Path("getCarInsuranceList")
    @Produces(MediaType.APPLICATION_JSON)
    public List<CarInsurance> getCarInsuranceList(@FormParam("startDate") String startDate,
                                                  @FormParam("endDate") String endDate,
                                                  @FormParam("carInsuranceStatus") CarInsuranceStatus carInsuranceStatus) {
        List<CarInsurance> requests = carInsuranceDao.listCarInsurance(DateUtils.FIRST_DATE,
                                                                       new Date(),
                                                                       PageInfo.ALL,
                                                                       carInsuranceStatus).getResults();
        return requests;
    }


这样一般来说肯定在服务启动时候就会报错的:

CarInsuranceStatus), should not consume any form parameter.;

2 解决方法

如果注解使用的@GET标注的,则使用@QueryParam

如果注解使用的@POST标注的,则使用@FormParam

3  如下改正后的代码:

    
    @GET
    @Path("getCarInsuranceList")
    @Produces(MediaType.APPLICATION_JSON)
    public List<CarInsurance> getCarInsuranceList(@QueryParam("startDate") String startDate,
                                                  @QueryParam("endDate") String endDate,
                                                  @QueryParam("carInsuranceStatus") CarInsuranceStatus carInsuranceStatus) {
        List<CarInsurance> requests = carInsuranceDao.listCarInsurance(DateUtils.FIRST_DATE,
                                                                       new Date(),
                                                                       PageInfo.ALL,
                                                                       carInsuranceStatus).getResults();
        return requests;
    }

4 参考别人说法地址: http://stackoverflow.com/questions/17125747/jersey-should-not-consume-any-form-parameter-exception

目录
相关文章
|
Web App开发 前端开发
【前端异常】Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
【前端异常】Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
786 0
Unable to interpret the implicit parameter configuration with dataType: , dataTypeClass: class java.
Unable to interpret the implicit parameter configuration with dataType: , dataTypeClass: class java.
562 0
|
3月前
|
Docker 容器
成功解决:Caused by: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but
这篇文章讨论了在使用Docker启动Elasticsearch容器时遇到的一个具体问题:由于配置文件`elasticsearch.yml`解析出错导致容器启动失败。文章提供了详细的排查过程,包括查看容器的日志信息、检查并修正配置文件中的错误(特别是空格问题),并最终成功重新启动了容器。
|
5月前
|
存储 缓存 自然语言处理
“error“: { “root_cause“: [{ “type“: “circuit_breaking_exception“, “reason“: “[parent] D【已解决】
“error“: { “root_cause“: [{ “type“: “circuit_breaking_exception“, “reason“: “[parent] D【已解决】
47 1
|
4月前
|
Java 数据库连接 mybatis
Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid
Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid
|
5月前
|
Java Spring
【已解决】Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception .lang.NullPointerEx
【已解决】Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception .lang.NullPointerEx
80 0
|
Java 应用服务中间件 Linux
SpringBoot - Processing of multipart/form-data request failed. Unexpected EOF read on the socket
SpringBoot - Processing of multipart/form-data request failed. Unexpected EOF read on the socket
1544 0
SpringBoot - Processing of multipart/form-data request failed. Unexpected EOF read on the socket
|
Java
【Java异常】Feign常见的坑总结之一:Method Not Allowed“,“message“:“Request method ‘POST‘ not supported“,“path“:“/*
【Java异常】Feign常见的坑总结之一:Method Not Allowed“,“message“:“Request method ‘POST‘ not supported“,“path“:“/*
255 0
|
Java Spring
【feign】Could not write request: no suitable HttpMessageConverter found for request type
【feign】Could not write request: no suitable HttpMessageConverter found for request type
573 0
WARN FileInputDStream:87 - Error finding new filesjava.lang.NullPointerException报错为什么
WARN FileInputDStream:87 - Error finding new filesjava.lang.NullPointerException报错为什么