在GET中将@转换为%40 - 使用Swagger UI + Spring Rest

时间:2017-06-29 13:29:34

标签: java spring swagger swagger-ui spring-restcontroller

我在swagger-ui GET电子邮件服务中提供了一个正确的电子邮件参数作为请求的一部分,它应该返回带有响应json对象的200,但它返回404并且电子邮件在那里在数据库中,何时

我注意到它在url请求中将@更改为%40 http://localhost:8080/EmailApp/user/email/test%40email.com

以下是我的restful web服务方法

@ApiOperation(value = "Returns a user by email", notes = "Returns a user 
and its details by email.", response = User.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "Successful retrieval of a User", response = User.class),
        @ApiResponse(code = 404, message = "User with given email does not exist"),
        @ApiResponse(code = 500, message = "Internal server error")}
)
@RequestMapping(value = "/user/email/{email}", method = RequestMethod.GET)
public ResponseEntity<?> getUserByEmail(@ApiParam(name = "email", value = "The user email", required = true)@PathVariable("email") String email) {
    log.info("Fetching User with email {}", email);
    User user = userService.findByEmail(email);
    if (user == null) {
        log.error("User with email {} not found.", email);
        return new ResponseEntity(new CustomErrorType("User with email " + email
                + " not found"), HttpStatus.NOT_FOUND);
    }
    return new ResponseEntity<>(user, HttpStatus.OK);
}

如何确保在GET http协议中的url请求中保留了@?

0 个答案:

没有答案