返回时返回新的ResponseEntity <>(jsonObject,HttpStatus.BAD_REQUEST);在下面的代码中,我在其中打印以下行:LOG.trace(“提供了无效的客户端”);在其他部分
@Action("VALIDATE")
@RequestMapping(value = "/validate", method = RequestMethod.POST)
public ResponseEntity<JSONObject> valCode(HttpServletRequest request, String userId, String code,
HttpServletResponse response) throws IOException, TokenIssuerException {
JSONObject jsonObject = new JSONObject();
if (code != null) {
ICode cacheCode = tokenCache.getCode(code, null);
IClientInfo clientInfo = clientAuthCore.getClient(request, response, true);
boolean checkClientId = checkClientID(clientInfo, cacheCode);
if (checkClientId) {
//业务逻辑
} else {
LOG.trace("Invalid Client provided");
return new ResponseEntity<>(jsonObject, HttpStatus.BAD_REQUEST);
}
} else {
LOG.trace("Invalid parameters");
return new ResponseEntity<>(jsonObject, HttpStatus.BAD_REQUEST);
}
}
答案 0 :(得分:0)
我将返回null,而不是另一个JSON对象,因为已调用getwrite,因此它是解决方案。