Project/AWS-Final

최종 프로젝트(13) - AWS 풀스택 과정 102일차

awspspgh 2024. 12. 23. 10:54

에러 고치기

 

GetMapping("/") -> getmapping이라서 redirect를 붙여야하고 "/"를 썼기에 "/index"가 아닌 "/"를 사용해야 함

 @GetMapping("/")
    public String showWeatherForm(@RequestParam(name = "address", required = false) String address, Model model, Principal principal) {
    @PostMapping("/register")
    public String register(@ModelAttribute BoardVO boardVO, Principal principal){
        log.info("boardVO >>> {} ", boardVO);

        Long userNum = Long.valueOf(principal.getName());

        log.info(">>> userNum >> {}", userNum);

        boardVO.setSellerId(userNum); // sellerId가 userNum

        long isOk = boardService.register(boardVO);

        log.info("isOk >>>> {}", isOk);

        return (isOk > 0) ? "/index" : "redirect:/board/register";
    }

 

    @PostMapping("/register")
    public String register(@ModelAttribute BoardVO boardVO, Principal principal){
        log.info("boardVO >>> {} ", boardVO);

        Long userNum = Long.valueOf(principal.getName());

        log.info(">>> userNum >> {}", userNum);

        boardVO.setSellerId(userNum); // sellerId가 userNum

        long isOk = boardService.register(boardVO);

        log.info("isOk >>>> {}", isOk);

        return (isOk > 0) ? "redirect:/" : "redirect:/board/register";
    }