html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:if="${#strings.length(data.message) != 0}">
<script>
top.alert("[[${data.message}]]");
</script>
</th:block>
<th:block th:if="${#strings.length(data.href) != 0}">
<script>
top.location.href = '[[${data.href}]]';
</script>
</th:block>
</head>
</html>
alert message class
@Getter
@Setter
public class Message {
String message = "";
String href = "";
public Message(String message, String href) {
this.message = message;
this.href = href;
}
}
Controller
@PostMapping(value = "/validCheck")
public ModelAndView validCheck(@ModelAttribute @Valid MemberDto memberDto, ModelAndView mav){
mav.addObject("data", new Message("alret Message", "/view/main"));
mav.setViewName("view/Message");
return mav;
}
'JAVA > 1' 카테고리의 다른 글
@Valid / ConstraintViolationException (0) | 2022.05.17 |
---|---|
Model / ModelAndView 정리 (0) | 2022.05.15 |
ExceptionHandler 예외처리 @ControllerAdvice 정리 (0) | 2022.05.11 |
@RequestParam @RequestBody @ModelAttribute (0) | 2022.05.07 |
Content-Type (0) | 2022.05.06 |