Filter ➔ DispatcherServlet ➔ HandlerMapping ➔ HandlerInterceptor ➔ Controller ➔ Service ➔ Repository(Mapper) ➔ ViewResolver
//요청별로 Map을 가짐
Map<String, Command> getMap;
Map<String, Command> postMap;
//접두어,접미어
String prefix = "/WEB-INF/views/";
String suffix = ".jsp";
public void init() {
getMap = new HashMap<>();
postMap = new HashMap<>();
createMap(getMap, postMap);
}
String prefix = "/WEB-INF/views/";
String suffix = ".jsp";
public void execute(Command command, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String viewName = command.execute(request, response);
if(viewName.startsWith("redirect:")) {
response.sendRedirect(viewName.substring("redirect:".length()));
} else {
String view = prefix + viewName + suffix;
request.getRequestDispatcher(view).forward(request, response);
}
}