<%@ page trimDirectiveWhitespaces="true" %>

咱們常常會在JSP頁面上使用:html

<%@ page trimDirectiveWhitespaces="true" %>
這個命令能夠使jsp輸出的html時去除多餘的空行(jsp上使用EL和tag會產生大量的空格和空行)。web

可是這個命令是從JSP2.1規範之後才獲得支持。tomcat

因此在tomcat 6.0以前的版本上若是使用這個命令就會拋出異常:jsp

Page directive has invalid attribute: trimDirectiveWhitespaceside

解決方法是:spa

1.升級tomcat至6.0以上版本.net

2.Tomcat 5.5.x+,不要使用trimDirectiveWhitespaces,改用這種方法:orm

在Tomcat安裝目錄/conf/web.xml中找到名叫"jsp"的servlet,添加下面一段代碼:xml


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


查看JSP版本能夠使用下面的命令:

JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %>


參考:

http://blog.csdn.net/xuhaiyang/article/details/2472591

http://blog.163.com/liubinguang1@126/blog/static/485470442015982160854/

相關文章
相關標籤/搜索