Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/com/example/bcsd/ArticleController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.example.bcsd;

public class ArticleController {
Copy link

Choose a reason for hiding this comment

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

상태코드 반환에 대해서는 ResponseEntity 참고해보시면 좋을거같아요

Choose a reason for hiding this comment

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

옙. @ResponseEntity에 대해 알아보겠습니다.

}
31 changes: 27 additions & 4 deletions src/main/java/com/example/bcsd/HelloController.java
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
Copy link

Choose a reason for hiding this comment

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

이렇게 객체를 반환할때 json으로 바뀌는걸 직렬화라고 하는데 한번 알아보시면 좋을거같아요

Choose a reason for hiding this comment

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

알려주셔서 감사합니다. 관련된 내용에 대해 꼭 알아보겠습니다.

public static class hello3{
Copy link

Choose a reason for hiding this comment

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

클래스명 첫글자는 대문자로 해주세요👍

Choose a reason for hiding this comment

The 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;
}
}

}
2 changes: 1 addition & 1 deletion src/main/resources/templates/hello.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<title>안녕하세요</title>
</head>
<body>
<p>안녕!!!</p>
<p th:text="'안녕하세요 제 이름은 ' + ${name} + '입니다!'"></p>
</body>
</html>