Skip to content
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단계] 아벨(신준혁) 미션 제출합니다. #608

Merged
merged 9 commits into from
Sep 25, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,6 @@ private void process(final HttpServletRequest request, final HttpServletResponse
final ModelAndView modelAndView = handlerAdapter.handle(handler, request, response);
final View view = modelAndView.getView();

move(view.getViewName(), request, response);
}

private void move(
final String viewName,
final HttpServletRequest request,
final HttpServletResponse response
) throws Exception {
if (viewName.startsWith(JspView.REDIRECT_PREFIX)) {
response.sendRedirect(viewName.substring(JspView.REDIRECT_PREFIX.length()));
return;
}

final var requestDispatcher = request.getRequestDispatcher(viewName);
requestDispatcher.forward(request, response);
view.render(modelAndView.getModel(), request, response);
Comment on lines 49 to +51
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModelAndView가 model과 view를 모두 알고 있으니,
ModelAndView.render(request, response)로 묶어주는 것도 괜찮아보여요!

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@

public interface View {
void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception;

String getViewName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@ public void render(final Map<String, ?> model, final HttpServletRequest request,
final PrintWriter writer = response.getWriter();
writer.write(body);
}

@Override
public String getViewName() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,4 @@ public void render(final Map<String, ?> model, final HttpServletRequest request,
final RequestDispatcher requestDispatcher = request.getRequestDispatcher(viewName);
requestDispatcher.forward(request, response);
}

public String getViewName() {
return viewName;
}
}
Loading