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://*.com/questions/17125747/jersey-should-not-consume-any-form-parameter-exception