Skip to content

4주차 미션 / 서버 3조 임지예#5

Open
ljyljy020202 wants to merge 5 commits intoKonkuk-KUIT:mainfrom
ljyljy020202:4week
Open

4주차 미션 / 서버 3조 임지예#5
ljyljy020202 wants to merge 5 commits intoKonkuk-KUIT:mainfrom
ljyljy020202:4week

Conversation

@ljyljy020202
Copy link
Copy Markdown

No description provided.

@ljyljy020202 ljyljy020202 changed the title 4주차 미션 / 3조 임지예 4주차 미션 / 서버 3조 임지예 Apr 9, 2025
Copy link
Copy Markdown
Contributor

@kisusu115 kisusu115 left a comment

Choose a reason for hiding this comment

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

굉장히 이상적으로 잘 작성해주신 것 같습니다!
jsp 파일의 위치까지 고려한 야무진 구조 같다는 생각이 듭니다.

추가적인 생각해볼 점들만 남겨보겠습니다.

public class ListUserController implements Controller{
@Override
public String execute(HttpServletRequest req) throws IOException {
HttpSession session = req.getSession(false); // false로 해야 세션이 없으면 새로 만들지 않음
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HttpSession 객체의 생성 여부까지 디테일하게 잡아주신 것 너무 좋습니다!

} else {
RequestDispatcher dispatcher = req.getRequestDispatcher("/WEB-INF/views" + viewPath + ".jsp");
dispatcher.forward(req, resp);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WEB-INF 보안 폴더 내부로 jsp 파일 옮겨주신 것 너무 좋습니다!
JSP 기반의 MVC 프로젝트에서 클라이언트의 접근을 제어한 이상적인 구조라고 생각되네요.

<c:otherwise>
<a href="/user/login" class="btn btn-outline-primary me-2">Log-In</a>
<a href="/user/form" class="btn btn-primary">Sign-up</a>
</c:otherwise>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

href 경로 변경까지 깔끔하게 잘 처리해주셨네요!

for (String key : keys) {
if (path.equals(key)) {
controller = controllers.get(key);
break;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

바라보는 관점과 상황에 따라 다르겠지만, 단순히 Map의 get() 메소드를 활용하는 대신 이렇게 구현함으로서 equals 뿐만이 아닌 다른 조건들도 추가하여 활용할 수 있을 것 같아 확장면에서 좋은 코드라는 생각이 듭니다!

@Override
public String execute(HttpServletRequest req) throws IOException {
return req.getRequestURI();
}
Copy link
Copy Markdown
Contributor

@kisusu115 kisusu115 Apr 13, 2025

Choose a reason for hiding this comment

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

이러한 형태의 ForwardController의 경우, jsp 파일의 위치와 요청 url이 일치해야한다는 단점이 존재할 것 같습니다!

에를들어 /user/list.jsp에 대한 요청이라면 반드시 /user/list와 매핑되는 구조이기에, 사실상 jsp 파일의 경로가 보이는 것 같은 느낌이 드네요. 예시 코드 4week/step2-mvc 브랜치의 ForwardController 클래스처럼 url 커스텀이 가능한 형태로 구현해주는 것도 좋다고 생각합니다!

물론 정답은 없기에, 의도에 따라 이 방식이 직관적이고 간단하게 구현될수도 있을 것 같아요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants