jsp开发的网页如何避免html头上的大段空白,jsp开发html头上,默认情况下jsp页面输出
分享于 点击 38111 次 点评:136
jsp开发的网页如何避免html头上的大段空白,jsp开发html头上,默认情况下jsp页面输出
默认情况下jsp页面输出的html页面中有很多行的空白,可以通过设置page
的trimDirectiveWhitespaces
属性来避免这些空白:
如下jsp page指令设置:
<%@ page trimDirectiveWhitespaces="true" %>
或者你也可以在配置文件web.xml中配置一下,这样项目中的所有页面都不需要设置这个属性了
<jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <trim-directive-whitespaces>true</trim-directive-whitespaces> </jsp-property-group></jsp-config>
用户点评