함수를 쓰는 방법

  • camel-case : DoItYourSelf (서버, 일반 개발자들 선호)
  • snake-case : do_it_yourself (js쪽 선호)

phoneNumber - getter & setter & toString 설정

@JsonProperty("phone_number")

@JsonNaming(value = PropertyNamingStrategies.SnakeCaseStrategy.class)

→ post method

User controller

put method

@PutMapping("/put")
public void put(@RequestBody Map<String, Object> requestData) {
    requestData.entrySet().forEach(stringObjectEntry -> {
        System.out.println("key : " + stringObjectEntry.getKey() +
                "value : " + stringObjectEntry.getValue());

reponse method

@PutMapping("put-object-entity")
public ResponseEntity<PostUserRequest> putObjectEntity(@RequestBody PostUserRequest requestData) {

    return  ResponseEntity.status(HttpStatus.CREATED).body(requestData);
}

→ Response 201 : created

@GetMapping("/get")
public PostUserRequest getUser() {
    PostUserRequest user = new PostUserRequest();
    user.setName("tester1234");

    return user;
}

HTML

  • 새로운 controller PageController
@Controller
public class PageController {
    @RequestMapping("/main")
    public String main() {
        return "main.html";

    }
}
  • resource에 static 폴더 - main.html 만들어주면

짜잔!


  • null값 빼고 response

@JsonInclude(JsonInclude.Include.*NON_NULL*)


⚠️ 화살표 디렉토리 수정
rm -rf .git
git rm --cached . -rf

0개의 댓글