-
Notifications
You must be signed in to change notification settings - Fork 25
[엄성현_BackEnd] 5주차 과제 제출합니다. #37
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
base: main
Are you sure you want to change the base?
Changes from all commits
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,4 @@ | ||
| package com.example.bcsd; | ||
|
|
||
| public class ArticleController { | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,43 @@ | ||
| package com.example.bcsd; | ||
|
|
||
| import org.springframework.stereotype.Controller; | ||
| import org.springframework.ui.Model; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import org.springframework.web.bind.annotation.ResponseBody; | ||
|
|
||
| @Controller | ||
| public class HelloController { | ||
|
|
||
| @ResponseBody | ||
| @GetMapping("/hello") | ||
| @GetMapping("/introduce0") | ||
| public String hello() { | ||
| return "Hello World!!!!!"; | ||
| return "안녕하세요 제 이름은 엄성현입니다"; | ||
| } | ||
|
|
||
| @GetMapping("/hello2") | ||
| public String hello2() { | ||
| @GetMapping("/introduce") | ||
| public String hello(@RequestParam(name="name") String name, Model model) { | ||
| model.addAttribute("name", name); | ||
| return "hello"; | ||
| } | ||
| @GetMapping("/json") | ||
| @ResponseBody | ||
| public hello3 getJsonDate(){ | ||
| return new hello3(23, "엄성현"); | ||
| } | ||
|
Comment on lines
+23
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이렇게 객체를 반환할때 json으로 바뀌는걸 직렬화라고 하는데 한번 알아보시면 좋을거같아요
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 알려주셔서 감사합니다. 관련된 내용에 대해 꼭 알아보겠습니다. |
||
| public static class hello3{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 클래스명 첫글자는 대문자로 해주세요👍
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 앞으로 꼭 대문자로 하겠습니다. |
||
| private int age; | ||
| private String name; | ||
| public hello3(int age, String name){ | ||
| this.age=age; | ||
| this.name=name; | ||
| } | ||
| public int getAge(){ | ||
| return age; | ||
| } | ||
| public String getName(){ | ||
| return name; | ||
| } | ||
| } | ||
|
|
||
| } | ||
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.
상태코드 반환에 대해서는 ResponseEntity 참고해보시면 좋을거같아요
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.
옙. @ResponseEntity에 대해 알아보겠습니다.