-
Notifications
You must be signed in to change notification settings - Fork 382
[MVC 구현하기 - 3단계] 카피(김상혁) 미션 제출합니다. #839
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6df6eb2
feat: UserController 추가
tkdgur0906 2616544
feat: JsonView 구현
tkdgur0906 b033bc1
feat: RequestMapping이 붙은 메서드만 스캔하도록 변경
tkdgur0906 a0ae761
refactor: legacy MVC를 어노테이션 기반으로 변경
tkdgur0906 6668266
refactor: DispatcherServlet mvc로 패키지 이동 및 패키지 분리
tkdgur0906 233f6d5
test: DI 학습 테스트 3단계
tkdgur0906 b7a0729
test: DI 학습 테스트 4단계
tkdgur0906 e1fa644
refactor: initializer 클래스 app으로 이동
tkdgur0906 1d55573
refactor: LoginController 메서드 분리
tkdgur0906 d6d55ff
refactor: DIContainer 메서드 분리
tkdgur0906 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
app/src/main/java/com/techcourse/DispatcherServletInitializer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
app/src/main/java/com/techcourse/ManualHandlerMapping.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/techcourse/controller/ForwardController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.techcourse.controller; | ||
|
|
||
| import com.interface21.context.stereotype.Controller; | ||
| import com.interface21.web.bind.annotation.RequestMapping; | ||
| import com.interface21.web.bind.annotation.RequestMethod; | ||
| import com.interface21.webmvc.servlet.ModelAndView; | ||
| import com.interface21.webmvc.servlet.view.JspView; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
|
|
||
| @Controller | ||
| public class ForwardController { | ||
|
|
||
| @RequestMapping(value = "/", method = RequestMethod.GET) | ||
| public ModelAndView forward(HttpServletRequest request, HttpServletResponse response) { | ||
| return new ModelAndView(new JspView("/index.jsp")); | ||
| } | ||
| } |
45 changes: 36 additions & 9 deletions
45
app/src/main/java/com/techcourse/controller/LoginController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
app/src/main/java/com/techcourse/controller/LoginViewController.java
This file was deleted.
Oops, something went wrong.
17 changes: 11 additions & 6 deletions
17
app/src/main/java/com/techcourse/controller/LogoutController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,21 @@ | ||
| package com.techcourse.controller; | ||
|
|
||
| import com.interface21.context.stereotype.Controller; | ||
| import com.interface21.web.bind.annotation.RequestMapping; | ||
| import com.interface21.web.bind.annotation.RequestMethod; | ||
| import com.interface21.webmvc.servlet.ModelAndView; | ||
| import com.interface21.webmvc.servlet.view.JspView; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import com.interface21.webmvc.servlet.mvc.asis.Controller; | ||
| import jakarta.servlet.http.HttpSession; | ||
|
|
||
| public class LogoutController implements Controller { | ||
| @Controller | ||
| public class LogoutController { | ||
|
|
||
| @Override | ||
| public String execute(HttpServletRequest req, HttpServletResponse res) throws Exception { | ||
| HttpSession session = req.getSession(); | ||
| @RequestMapping(value = "/logout", method = RequestMethod.GET) | ||
| public ModelAndView loginView(HttpServletRequest request, HttpServletResponse response) { | ||
| HttpSession session = request.getSession(); | ||
| session.removeAttribute(UserSession.SESSION_KEY); | ||
| return "redirect:/"; | ||
| return new ModelAndView(new JspView("redirect:/")); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/techcourse/controller/UserController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.techcourse.controller; | ||
|
|
||
| import com.interface21.context.stereotype.Controller; | ||
| import com.interface21.web.bind.annotation.RequestMapping; | ||
| import com.interface21.web.bind.annotation.RequestMethod; | ||
| import com.interface21.webmvc.servlet.ModelAndView; | ||
| import com.interface21.webmvc.servlet.view.JsonView; | ||
| import com.techcourse.domain.User; | ||
| import com.techcourse.repository.InMemoryUserRepository; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| @Controller | ||
| public class UserController { | ||
|
|
||
| private static final Logger log = LoggerFactory.getLogger(UserController.class); | ||
|
|
||
| @RequestMapping(value = "/api/user", method = RequestMethod.GET) | ||
| public ModelAndView show(HttpServletRequest request, HttpServletResponse response) { | ||
| final String account = request.getParameter("account"); | ||
| log.debug("user id : {}", account); | ||
|
|
||
| final ModelAndView modelAndView = new ModelAndView(new JsonView()); | ||
| final User user = InMemoryUserRepository.findByAccount(account) | ||
| .orElseThrow(); | ||
|
|
||
| modelAndView.addObject("user", user); | ||
| return modelAndView; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Initializer의 존재는 쓸만하신가요? 저도 생성을 전문으로 담당해주는 객체 분리를 고민중인데 카피 의견이 궁금하네요!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.
초기화하는 객체를 만드니까 더 명확해지는 장점이 있는 것 같아요!
결국 어딘가에서는 초기화를 해줘야 하는데, 다른 곳에 있으면 찾기 힘들수도 있을 것 같긴 합니다.
근데 이정도는 취향차이인 것 같긴합니다!