alert.jsp 알림창

팡태(❁´◡`❁)·2022년 3월 7일
0

java

목록 보기
27/36
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <script th:inline="javascript">
        const msg = [[${msg}]];
        alert(msg);
        window.location.replace([[${url}]]);
    </script>
</head>
<body>
    
</body>
</html>

controller

    @PostMapping(value = "/updatebatch")
    public String updatePOST(
        Model model,
        @RequestParam(name = "code") long[] code,
        @RequestParam(name = "title") String[] title,
        @RequestParam(name = "price") long[] price,
        @RequestParam(name = "writer") String[] writer,
        @RequestParam(name = "category") String[] category) {

            List<Book> list = new ArrayList<>();
            for (int i = 0; i < code.length; i++) {
                Book book = new Book();
                book.setCode(code[i]);
                book.setTitle(title[i]);
                book.setPrice(price[i]);
                book.setWriter(writer[i]);
                book.setCategory(category[i]);
                book.setRegdate(new Date());
    
                list.add(book);
            }
            long ret = bookDB.updateBatchBook(list);
            if(ret == 1){
                model.addAttribute("msg", "일괄수정 완료");
                model.addAttribute("url", "/admin/selectlist");
                return "alert";
            }
            // jsp를 만들어서 알림 띄우고  redirect 수행
            model.addAttribute("msg", "일괄수정 실패");
            model.addAttribute("url", "/admin/selectlist");
            return "alert";
        }

0개의 댓글