-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
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
[MVC 구현하기 - 3단계] 짱수(장혁수) 미션 제출합니다. #840
base: zangsu
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
짱수 안녕하세요
구현 너무 잘해주셨네요👍👍
코멘트 남겼으니 확인해주세요!
mvc/src/test/java/com/interface21/webmvc/servlet/mvc/framework/DispatcherServletTest.java
Show resolved
Hide resolved
mvc/src/main/java/com/interface21/webmvc/servlet/view/JsonView.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
@RequestMapping(value = "/api/user", method = RequestMethod.GET) | ||
public ModelAndView show(HttpServletRequest request, HttpServletResponse response) { | ||
final String account = request.getParameter("account"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"account" parameter가 2개 이상이면 어떻게 될까요?🤔
log.debug("Method : {}, Request URI : {}", request.getMethod(), requestURI); | ||
|
||
try { | ||
HandlerAdapter handlerAdapter = getHandlerAdapter(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어댑터 패턴을 사용했을 때 어떠한 장점이 있었나요?
HandlerAdapter handlerAdapter = getHandlerAdapter(request); | ||
ModelAndView modelAndView = handlerAdapter.handle(request, response); | ||
modelAndView.getView().render(modelAndView.getModel(), request, response); | ||
} catch (Throwable e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception
, Error
, Throwable
의 차이에 대해 알고 계신가요??
.map(handlerMappingAdapter -> handlerMappingAdapter.getHandler(request)) | ||
.filter(Objects::nonNull) | ||
.findFirst() | ||
.orElseThrow(() -> new NoMatchedHandlerException(request)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
처리할 핸들러가 없을 때 상태코드 500와 에러페이지를 보여 주고 있습니다.
사용자가 알 수 있도록 올바른 상태코드와 페이지를 보여주는 것이 어떨까요?
JspView view = UserSession.getUserFrom(req.getSession()) | ||
.map(user -> { | ||
log.info("logged in {}", user.getAccount()); | ||
return new JspView("redirect:/index.jsp"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JspView
이름에서 충분히 유추 가능하기 때문에 �확장자까지 주입할 필요는 없을거 같아요!
String key = model.keySet().stream() | ||
.findFirst() | ||
.get(); | ||
return objectMapper.writeValueAsString(model.get(key)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
values()
를 사용하면 조금 더 깔끔할 거 같아요!
handlerMappingAdapters = Stream.of(new AnnotationHandlerMappingAdapter(basePackage)) | ||
.map(adapter -> { | ||
adapter.initialize(); | ||
return (HandlerMappingAdapter) adapter; | ||
}).toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handlerMappingAdapters = Stream.of(new AnnotationHandlerMappingAdapter(basePackage))
.peek(AnnotationHandlerMappingAdapter::initialize)
.map(adapter -> (HandlerMappingAdapter) adapter)
.toList();
요렇게 표현해볼 수도 있을 거 같아요!
종이, 안녕하세요!
마지막 미션 제출이네요!!!
files changed 가 조금 많이 잡혔는데, 패키지 이동, 파일 삭제가 많아서 그렇습니다...ㅎㅎ
이번 리뷰도 잘 부탁드려요!!!!