jsp trimDirectiveWhitespaces ="true"(删除空白行)

jsp中会经常使用到使用jsp标签和jstl的标签,比如<%@ page ..%>, <%@ taglib ...%>, <c:forEach....%>, 尤其是循环标签,在jsp最终输出的html中会产生大量的空行,使得性能降低。

解决方法(1)(所有的jsp页面)在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页面)

在单个的jsp中添加<%@ page trimDirectiveWhitespaces="true"%>.tomcat 目录下 \conf\web.xml文件,在jsp servlet增加参数

解决方法(3)(servlet

tomcat 目录下 \conf\web.xml文件,在jsp servlet增加参数

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

猜你喜欢

转载自blog.csdn.net/prh1023/article/details/51434617
今日推荐