【发布时间】:2019-05-29 23:59:44
【问题描述】:
我已在 spring-boot 实现的 Web 应用程序的控制器中将路径变量从 String 更新为 UUID。我在前端使用 swagger。我在更改后的响应中收到“缺少 UUID 类型的方法参数的 URI 模板变量 'uuid'”异常。
我已在 spring-boot 实现的 Web 应用程序的控制器中将路径变量从 String 更新为 UUID。我在前端使用 swagger。在数据库方面,我使用的是 mongodb。我正在将此 uuid 转换为字符串以使用为 mongodb 实现的现有 find 方法。我在回复中收到此异常。同样的事情正在另一个项目中工作,找不到为什么它在这里不起作用。
@Path("/uuid")
@RequestMapping(value = "/uuid", method = { RequestMethod.GET })
@ResponseBody
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Retrieves result based on Unique Identifier", notes = "Returns result matching with the Unique Identifier",
position = 1, response = Response.class, httpMethod = "GET")
@ApiResponses(value = { @ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = "Invalid request."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Record not found."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Not authorized for this operation."),
@ApiResponse(code = HttpServletResponse.SC_CONFLICT, message = "Object state out-of-date."),
@ApiResponse(code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message = "Server error") })
ResponseEntity<Response> getResultByUuid(@ApiParam(required = true, name = "uuid", value = "uuid") @PathParam("uuid") @PathVariable("uuid") UUID uuid,
@ApiParam(access = "hidden") HttpServletRequest request)
throws IOException;
- 它应该取而代之的是我的结果。现在它抛出异常。它甚至没有到达控制器,怀疑一些弹簧配置依赖的东西。不知道那是什么?
【问题讨论】:
标签: java spring-boot spring-mvc