We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CurrentUserMethodArgumentResolver 这个类,没看到这个值怎么存入的,可以讲解下把。 @OverRide public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { //取出鉴权时存入的登录用户Id Long currentUserId = (Long) webRequest.getAttribute(Constants.CURRENT_USER_ID, RequestAttributes.SCOPE_REQUEST); if (currentUserId != null) { //从数据库中查询并返回 return userRepository.findOne(currentUserId); } throw new MissingServletRequestPartException(Constants.CURRENT_USER_ID); }
The text was updated successfully, but these errors were encountered:
//如果token验证成功,将token对应的用户id存在request中,便于之后注入 request.setAttribute(Constants.CURRENT_USER_ID, model.getUserId()); 找到了。在这里、
Sorry, something went wrong.
No branches or pull requests
CurrentUserMethodArgumentResolver 这个类,没看到这个值怎么存入的,可以讲解下把。
@OverRide
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
//取出鉴权时存入的登录用户Id
Long currentUserId = (Long) webRequest.getAttribute(Constants.CURRENT_USER_ID, RequestAttributes.SCOPE_REQUEST);
if (currentUserId != null) {
//从数据库中查询并返回
return userRepository.findOne(currentUserId);
}
throw new MissingServletRequestPartException(Constants.CURRENT_USER_ID);
}
The text was updated successfully, but these errors were encountered: