我使用招摇,现在我想捕获输入数据。 我的代码:
@GET @Path("/getById/{wId}") @Produces({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Get warehouse by id", notes = "Get warehouse by id", response = Warehouse.class) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid Id supplied"), @ApiResponse(code = 404, message = "Warehouse not found") }) public Response getWarehouseById( @ApiParam(value = "ID of warehouse to fetch", required = true) @PathParam("wId") int wId) throws WebApplicationException { Warehouse warehouse = warehouseService.findWarehouseByID(wId); if(warehouse != null && warehouse.getWareHouseID() != 0){ String[] errorMessage = new String[]{}; String[] message = new String[]{Constants.SUCCESS}; Object[] rows = new Object[]{warehouse}; return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.SUCCESS,errorMessage,rows,message)).build(); }else{ String[] errorMessage = new String[]{Constants.NOT_FOUND}; String[] message = new String[]{}; Object[] rows = new Object[]{}; return Response.status(ApiResponseMessage.NOT_FOUND).entity(new ApiResponseMessage(ApiResponseMessage.NOT_FOUND,errorMessage, rows, message)).build(); } }
如果我输入字符串值为int wId,我将得到结果
Can not construct instance of java.lang.Integer from String value 'int': not a valid Integer value
你能告诉我怎么修理吗? Tks all ...