sweetalert2
사용하는데 header.jsp에 불러놓고 다른페이지에서도 사용할수있게 하려는데
다른 팀원이 sweetalert2가 안된다고
다른 alert메세지를 타게 해놨었다
당시 해당코드
<c:if test="${ not empty alertMsg }">
<script>
alert("${ alertMsg }");
</script>
<c:remove var="alertMsg" scope="session" />
</c:if>
<!--
<c:if test="${ not empty alertMsg }">
<script>
$(function(){
Swal.fire({
icon:'${alertMsg.icon}',
title:'${alertMsg.title}',
text:'${alertMsg.text}',
})
});
<c:remove var="alertMsg" scope="session" />
</script>
</c:if>
-->
자세히 살펴보니 script 태그 안에 <c:remove var="alertMsg" scope="session" /> 가 있어서 작동이 안되는 거였고 script 태그 밖으로 해당코드를 빼주니 제대로 작동이 됐다.
그래서 머지하고 풀 받아서 <c:remove var="alertMsg" scope="session" />
코드를 script 태그 밖으로 빼도 안되는 사태가 발생,,
당시 해당코드
<!--
<c:if test="${ not empty alertMsg }">
<script>
alert("${ alertMsg }");
</script>
<c:remove var="alertMsg" scope="session" />
</c:if>
-->
<c:if test="${ not empty alertMsg }">
<script>
$(function(){
Swal.fire({
icon:'${alertMsg.icon}',
title:'${alertMsg.title}',
text:'${alertMsg.text}',
})
});
</script>
<c:remove var="alertMsg" scope="session" />
</c:if>
왜 안되지 하고 엄청나게 고민했는데
분명 alertMsg는 제대로 세션으로 가는거같은데 왜 안될까 하고 몇시간 잡아먹다가
설마 하면서 순서를 바꿔봤는데 sweetalert2가 되어버림
현재코드
<c:if test="${ not empty alertMsg }">
<script>
$(function(){
Swal.fire({
icon:'${alertMsg.icon}',
title:'${alertMsg.title}',
text:'${alertMsg.text}',
})
});
</script>
<c:remove var="alertMsg" scope="session" />
</c:if>
<!--
<c:if test="${ not empty alertMsg }">
<script>
alert("${ alertMsg }");
</script>
<c:remove var="alertMsg" scope="session" />
</c:if>
-->
왜인지는 모르겠으나.....대체왜? .. 순서만바꿔준건데
이렇게 하니까 됐다..
spring은 참 어렵다......