有一个trimWhiteSpaces指令可以完成此操作,
在您的JSP中:
<%@ page trimDirectiveWhitespaces="true" %>
或在jsp-config部分中的web.xml(请注意,此操作从Servlet规范2.5开始。):
<jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <trim-directive-whitespaces>true</trim-directive-whitespaces> </jsp-property-group></jsp-config>
不幸的是,如果您有所需的空间,则可能还需要剥离该空间,因此在某些位置可能需要不间断的空间。



