Project/Study Website Project
[String Boot Project] 게시글 메시지
seung_hyeon
2025. 1. 20. 21:34
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";
}

