티스토리 뷰

jsp 를 사용하다 보면 jstl이 있던 자리가 html로 변경되고 나서 빈줄(whitespace)로 남아있는 것을 보게 된다. 크게 문제는 없지만 깔끔해 보이지도 않고 파일의 용량도 늘어나게 되니 없애고 싶다. 그럴 때 선택할 수 있는 방법이 몇 가지 있다.

Jsp에 선언하는 방법

<%@ page trimDirectiveWhitespaces="true" %>

web.xml에 설정하는 방법

<jsp-config>
  <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <trim-directive-whitespaces>true</trim-directive-whitespaces>
  </jsp-property-group>
</jsp-config>

Tomcat의 conf/web.xml에 설정하는 방법

<init-param>
    <param-name>trimSpaces</param-name>
    <param-value>true</param-value>
</init-param>


출처 : http://chomman.github.io/blog/java/jsp/jstl/strip-white-space-on-jsp/

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함