jsp移除页面的头部空白行列

星期二, 2013-11-26 | Author: Lee | JAVA-and-J2EE | 4,850 views

看着jsp页面的头部的空白行感觉不是很好看,想移除,记得以前做wap的时候也是不允许前面有空白的.

方法如下:
第一种:

<%out.clear();%>

弊端后面的部分都要紧跟向前缩进不推,主要是自己也还是暂用一行空白不推荐
第二种:
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>

Tags:

文章作者: Lee

本文地址: https://www.pomelolee.com/1262.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

No comments yet.

Leave a comment

Search

文章分类

Links

Meta