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

[Spring MVC] 한재원 미션 제출합니다 #324

Open
wants to merge 2 commits into
base: breadquokka
Choose a base branch
from

Conversation

BreadQuokka
Copy link

2단계 구현 중 html 페이지가 켜지지 않는데 왜 그럴까요..?

@GetMapping(value= "/reservation",produces = "text/html")
public String world(Model model) {
model.addAttribute("reservationData", reservation);
return "reservationpage";//html 페이지를 못찾아요
Copy link
Author

Choose a reason for hiding this comment

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

html실행이 안되고, reservationpage라는 문자열만 나타나요..

Choose a reason for hiding this comment

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

@RestController 대신 @Controller를 사용하면 아마 html 페이지가 잘 응답할 거에요~
@RestController@Controller는 무슨 차이가 있길래 이런 일이 발생한 것일까요?

Copy link

@kwonyj1022 kwonyj1022 left a comment

Choose a reason for hiding this comment

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

개인적으로 궁금한 사항과 제안 사항이 있어서 리뷰 달아봤어요~
아직 구현이 완료되지 않은 것 같은데 나머지 부분 구현해서 push 해주시면 좋을 것 같아요!

@GetMapping(value= "/reservation",produces = "text/html")
public String world(Model model) {
model.addAttribute("reservationData", reservation);
return "reservationpage";//html 페이지를 못찾아요

Choose a reason for hiding this comment

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

@RestController 대신 @Controller를 사용하면 아마 html 페이지가 잘 응답할 거에요~
@RestController@Controller는 무슨 차이가 있길래 이런 일이 발생한 것일까요?

List<Reservation> reservation = new ArrayList<>();// 전역변수.

@GetMapping("/reservationData")

Choose a reason for hiding this comment

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

공백이 이상하게 들어가있네요 🥲


@GetMapping(value= "/reservation",produces = "text/html")
public String world(Model model) {
model.addAttribute("reservationData", reservation);

Choose a reason for hiding this comment

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

이 속성이 html에 존재하는 속성인가요? 어떤 이유로 추가해 주셨나요~?

Comment on lines +9 to +17
// 생성자
public Reservation(String id, String name, String date, String time) {
this.id = id;
this.name = name;
this.date = date;
this.time = time;
}

// getter와 setter

Choose a reason for hiding this comment

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

이러한 주석은 주석 없이도 메서드이름만으로 그 역할을 잘 나타내기 때문에 굳이 필요 없을 것 같습니다!

<a href="/">
<a href="/static">

Choose a reason for hiding this comment

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

이렇게 수정하신 이유가 궁금해요!

import java.util.List;

@RestController
//@RequestMapping("/reservation")

Choose a reason for hiding this comment

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

불필요한 주석은 제거해 주세요~

//@RequestMapping("/reservation")
public class ReservationController {

List<Reservation> reservation = new ArrayList<>();// 전역변수.

Choose a reason for hiding this comment

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

여기 주석도 마찬가지!

Comment on lines +23 to +28
// 예약 목록을 담을 리스트 생성

reservation.add(new Reservation("1", "브라운", "2023-01-01", "10:00"));
reservation.add(new Reservation("2", "브라운", "2023-01-02", "11:00"));

// 예약 목록 반환

Choose a reason for hiding this comment

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

이 주석도 굳이 없어도 코드를 이해하는 데 문제가 없기 때문에 없어도 될 것 같네요

Comment on lines +3 to +7
public class Reservation {
private String id;
private String name;
private String date;
private String time;
Copy link

@kwonyj1022 kwonyj1022 Aug 4, 2024

Choose a reason for hiding this comment

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

id가 식별자의 역할을 하고 있는데요, 그렇다면 id가 동일하면 동일한 객체인데, 지금 상태로는 new를 통해 id가 같은 객체를 두 개 만들면 두 객체가 다른 객체로 인식될 거예요. 그 이유는 무엇이고, 이를 방지하기 위해 어떤 것을 할 수 있을까요?

Comment on lines +23 to +24
//@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
//@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD)

Choose a reason for hiding this comment

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

여기도 주석 제거해주세요!

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