1. input 태그에 데이터를 넣는다.
jsp 에서는 escapeXml true 옵션을 주어 처리한다.
2. 자바스크립트로, \n 는 br 로 변경해 주며, jquery 에서 html 로 뿌려주는 방식으로
처리해 주면된다.
<c:forEach items="${paging.result}" var="item" varStatus="vs">
<span class="a_count"></span>
<div>
~
<div id="a_${vs.index}"></div>
<input type="hidden" id="a_${vs.index}" value="<c:out value="${item.a}" escapeXml="true" />">
<div id="b_${vs.index}"></div>
<input type="hidden" id="b_${vs.index}" value="<c:out value="${item.b}" escapeXml="true" />">
<div id=" c_${vs.index}"></div>
<input type="hidden" id="c_${vs.index}" value="<c:out value="${item.c}" escapeXml="true" />">
</div>
</c:forEach>
<script>
$(function(){
const aCnt =$(".a_count").length;
console.log(aCnt )
for(let i=0; i<=aCnt ; i++){
$("#a"+i).html(replaceBrTag($("#a"+i).val()));
$("#b"+i).html(replaceBrTag($("#b"+i).val()));
$("#c"+i).html(replaceBrTag($("#c"+i).val()));
}
});
function replaceBrTag(str){
if (str == undefined || str == null){
return "";
}
str = str.replace(/\r\n/ig, '<br>');
str = str.replace(/\\n/ig, '<br>');
str = str.replace(/\n/ig, '<br>');
return str;
}
</script>













댓글 ( 4)
댓글 남기기