Message.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<script th:inline="javascript">
/*<![CDATA{*/
var message = [[${message}]];
alert(message);
location.replace([[${searchURL}]]);
/*]]>*/
</script>
<body>
</body>
</html>
커트롤러에서 메시지를 담아서 전송 → alert 창 출력
PostController
@PostMapping("/post/writePro")
public String postWritePro(Post post, Model model) {
postService.write(post);
model.addAttribute("message", "글 작성이 완료 되었습니다.");
model.addAttribute("searchURL", "/post/list");
return "Message";
}


'Project > Study Website Project' 카테고리의 다른 글
| [Spring Boot Project] 페이징 처리 (0) | 2025.01.21 |
|---|---|
| [String Boot Project] 파일 업로드 (0) | 2025.01.20 |
| [Spring Boot Project] 게시글 삭제 및 수정 (0) | 2025.01.14 |
| [Spring Boot Project] 게시글 리스트 및 상세 페이지 (0) | 2025.01.14 |
| [Spring Boot Project] 게시글 생성 (0) | 2025.01.13 |