컨트롤러 블로그 컨텐츠 저장 메서드 작성

블로그 컨텐츠 저장 메서드 작성 개요

서비스를 이용해서 블로그 컨텐츠를 저장하는 메서드를 작성합니다.

postCreate 메서드 작성


/src/main/java/v2/mvc/spring/blog/controller/BlogController.java

public String postCreate(@RequestParam Map<String, Object> map) {
    int blogContSeq = this.blogService.create(map);
    return "redirect:/read/" + String.valueOf(blogContSeq);
}
  1. create 메서드 아래에 postCreate 메서드를 작성합니다.
  2. 자동 불러오기 를 통해 패키지를 채웁니다.

RequestMapping POST 붙이기

@RequestMapping(value="/create", method=RequestMethod.POST)
  1. create 메소드의 @RequestMapping 줄을 복사합니다.
  2. PostCreate 메소드 위에 붙여넣습니다.
  3. method=RequestMethod.GETmethod=RequestMethod.POST 로 변경합니다.

create 메소드 이름 getCreate로 변경하기

public String getCreate() {
  1. create 메소드 이름을 getCreate 로 변경합니다.