java Spring安全性通过控制器进行身份验证
我正在尝试创建一个简单的控制器供客户端登录。作为回应,我想给他们发一个号码(假设这是玩家的id)
我已经有了一个定制的spring安全授权机制
@RequestMapping(value = "/login", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public int login(@RequestBody loginDTO loginDTO, HttpServletRequest request, HttpServletResponse response) throws IOException,
ServletException {
this.authenticationProvider.manualAuthentication(
loginDTO,
request,
response);
/hard coded id for the example purpose
return 123;
}
显然,现在客户端ajax调用收到一个错误!(data.responseText包含html格式的登录页面。为什么?)
解决此问题的线索:
当我评论这句话时:
this.authenticationProvider.manualAuthentication(
loginDTO,
request,
response);
它按预期工作(当然没有进行身份验证,但是结果数据成功地传递给了客户机),因此显然身份验证调用在某种程度上转换了响应对象
有什么想法吗
共 (0) 个答案