邮递员IllegalArgumentException:目标对象不能为null”,

时间:2018-08-28 07:21:42

标签: java spring spring-boot postman

我是邮递员的新手。当我输入一些有关邮递员的信息时,下面出现错误;

{
    "timestamp": "2018-08-28T07:18:24.540+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "Target object must not be null; nested exception is java.lang.IllegalArgumentException: Target object must not be null",
    "path": "/userRight/create"
}


@RequestMapping(value = "userRight/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    // @Transactional(rollbackFor = Exception.class)
    public ResponseEntity<CreateUserRightResponseType> createUserRight(@RequestBody CreateUserRightRequestType request)
            throws UserRightException {

        CreateUserRightResponseType response = new CreateUserRightResponseType();

        try {
            userRightService.createUserRight(request.getUserRightType());
            response.setStatus(ResponseStatusCodes.SUCCESS);
            return new ResponseEntity<>(response, HttpStatus.OK);

        } catch (UserRightException e) {
            response.setStatus(ResponseStatusCodes.ERROR);
            response.setErrorMessage(e.getLocalizedMessage());
            return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
        }

    }

}

有什么建议吗?

0 个答案:

没有答案