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
안녕하세요, 2차시 세션에서 설명이 제대로 이루어지지 않은 부분이 있었는데요!
저희가 package javax.servlet.http 안에 있는 HttpServletRequest를 사용해서 setAttribute 해주기 때문에, 어트리뷰트를 가져올 때도 이 객체로부터 정보를 얻어와야 합니다.
package javax.servlet.http
request.getAttribute() 메소드를 사용할 때, 스프링에 내장된 NativeWebRequest 타입의 getAttribute 메소드는 시그니처로 name뿐만 아니라 scope를 받습니다. 스코프는 세션 레벨에서의 다양한 정보 저장을 위한 기능인데요,
scope
아래처럼 NativeWebRequest 타입의 요청을 ServletWebRequest라는 객체로 감싸주면 (어댑터 클래스입니다), 그 객체 내부에 있는 request 프로퍼티를 통해 인터셉터에서 가로챘던 HttpServletRequest 에 접근할 수 있습니다.
NativeWebRequest
ServletWebRequest
override fun resolveArgument( parameter: MethodParameter, mavContainer: ModelAndViewContainer?, webRequest: NativeWebRequest, binderFactory: WebDataBinderFactory? ): Any? { parameter.hasMethodAnnotation(UserContext::class.java) val password = (webRequest as ServletWebRequest).request.getAttribute("pwd") return password }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
안녕하세요, 2차시 세션에서 설명이 제대로 이루어지지 않은 부분이 있었는데요!
저희가
package javax.servlet.http
안에 있는 HttpServletRequest를 사용해서 setAttribute 해주기 때문에, 어트리뷰트를 가져올 때도 이 객체로부터 정보를 얻어와야 합니다.request.getAttribute() 메소드를 사용할 때, 스프링에 내장된 NativeWebRequest 타입의 getAttribute 메소드는 시그니처로 name뿐만 아니라
scope
를 받습니다. 스코프는 세션 레벨에서의 다양한 정보 저장을 위한 기능인데요,아래처럼
NativeWebRequest
타입의 요청을ServletWebRequest
라는 객체로 감싸주면 (어댑터 클래스입니다),그 객체 내부에 있는 request 프로퍼티를 통해 인터셉터에서 가로챘던 HttpServletRequest 에 접근할 수 있습니다.
The text was updated successfully, but these errors were encountered: