使用JSP的时候,由于标签的关系,页面解析完之后,经常会出现很多空白行
还有一种情况就是响应结果中也会包含回车符或者空行
解决这个问题有两种方式:
全局配置:
在web.xml中添加如下配置
<jsp-config>
<!--去除jsp中的空白行-->
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<trim-directive-whitespaces>true </trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
单个文件配置:
<%@ page trimDirectiveWhitespaces="true" %>
注:该方式不支持【Tomcat6.0】以下版本