2014-05-24 2 views
3

JSP 태그 뒤에 줄 바꿈을 제거하는 방법은 무엇입니까?JSP 태그 뒤에 줄 바꿈을 제거하는 방법은 무엇입니까?

예를 들어, JSP 페이지의 출력 결과에서보다이

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>${pageTitle}</title> 
    </head> 

같은 태그 코드가있는 경우 라인 하나에 하나의 줄 바꿈 될 것입니다.

!HERE_LINE_BREAK! 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title></title> 
    </head> 

첫 번째 줄에서 불필요한 줄 바꿈을 제거하는 방법은 무엇입니까?

JSP는 Spring Web MVC로 처리됩니다.

감사합니다. 이 시작 작동

<%@ page trimDirectiveWhitespaces="true" %> 

을 또는 JSP-설정 섹션에서의 web.xml은 (참고 :

+0

대단히 감사합니다, 바트! –

답변

2

는 JSP에서 Strip whitespace from jsp output 이 작업을 수행해야 trimWhiteSpaces 지침이 있습니다에서

을 복사 서블릿 사양 2.5에서.) :

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

불행히도 필요한 공간이 있다면, 따라서 일부 위치에서는 깨지지 않는 공간이 필요할 수 있습니다.

관련 문제