1、在工程的web.xml上加上如下配置
<jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <trim-directive-whitespaces>true</trim-directive-whitespaces> </jsp-property-group> </jsp-config>
2、在每个JSP的头上加上一段代码
<%@ page trimDirectiveWhitespaces="true" %>
以上两种方法取其一即可,建议使用第一种。
web.xml 中的配置需在servlet2.5(tomcat6.0)以上才能用。