关于jsp头部出现大量空白行的解决方法

正常情况应该是使用了 <%@include%>

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. 在tomcat 的配置文件 web.xml中找到 jspServlet 加入以下配置

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

</init-param>

trimSpaces参数介绍

Should white spaces in template text between actions or directives be trimmed?

在模板文本中,操作或指令之间的空格应该被删除吗?  

默认为false  修改为true 后会删除多余空格

3.也可以在单独jsp页面配置( 不推荐)

    在单独页面头处加上以下配置 

<%@ page trimDirectiveWhitespaces="true" %>



猜你喜欢

转载自blog.csdn.net/qq_39529839/article/details/79915113