-
Notifications
You must be signed in to change notification settings - Fork 164
[Spring MVC] 민지인 미션제출합니다 #503
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
Changes from 1 commit
d00ac48
5fddb60
a120bd3
b3cf994
81259f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package roomescape.controller; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.stereotype.Controller; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import roomescape.dto.Reservation; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Controller | ||
| public class ReservationController { | ||
|
|
||
| private List<Reservation> reservations = new ArrayList<>(); | ||
|
|
||
| @GetMapping("/reservation") | ||
| public String reservation(){ | ||
| return "/reservation.html"; | ||
| } | ||
|
|
||
| @GetMapping("/reservations") | ||
| public ResponseEntity<List<Reservation>> reservations(){ | ||
|
||
|
|
||
| Reservation reservation1=new Reservation(1L,"브라운","2023-01-01","10:00"); | ||
| reservations.add(reservation1); | ||
|
|
||
| return ResponseEntity.ok(reservations); | ||
|
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package roomescape.controller; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.stereotype.Controller; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
|
|
||
| @Controller | ||
| public class StartController { | ||
|
|
||
| @GetMapping("/") | ||
| public String home(){ | ||
| return "/home.html"; | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package roomescape.dto; | ||
|
|
||
| import java.sql.Date; | ||
| import java.sql.Time; | ||
| import java.time.LocalDate; | ||
| import java.time.LocalTime; | ||
|
|
||
| public class Reservation { | ||
| public Long id; | ||
|
||
| public String name; | ||
| public String date; //우선 String으로.. 차후 Date로 형변환 필요하면 교체.. | ||
| public String time; //동일!! | ||
|
|
||
| public Reservation(Long id,String name,String date,String time){ | ||
| this.id=id; | ||
| this.name=name; | ||
| this.date=date; | ||
| this.time=time; | ||
| } | ||
| } | ||
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.
뷰 이름만 사용하셔도 됩니다!
return "reservation"하셔도 자동으로 templates/reservation.html을 찾아서 렌더링할 거예요.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.
그리고 지금 Model 에 데이터가 없어요. 리스트를 담아서 전달해야 합니다~