首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

错误处理:Page directive has invalid attribute: trimDirectiveWhitespaces

2012-10-31 
异常处理:Page directive has invalid attribute: trimDirectiveWhitespaces我们经常会在JSP页面上使用:%

异常处理:Page directive has invalid attribute: trimDirectiveWhitespaces

我们经常会在JSP页面上使用:

<%@ page trimDirectiveWhitespaces="true" %>
这个命令可以使jsp输出的html时去除多余的空行(jsp上使用EL和tag会产生大量的空格和空行)。

?

但是这个命令是从JSP2.1规范以后才得到支持。

所以在tomcat 6.0之前的版本上如果使用这个命令就会抛出异常:

Page directive has invalid attribute: trimDirectiveWhitespaces

?

解决方法是:

1.升级tomcat至6.0以上版本

2.Tomcat 5.5.x+,不要使用trimDirectiveWhitespaces,改用这种方法:

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

错误处理:Page directive has invalid attribute: trimDirectiveWhitespaces<init-param>
错误处理:Page directive has invalid attribute: trimDirectiveWhitespaces<param-name>trimSpaces</param-name>
错误处理:Page directive has invalid attribute: trimDirectiveWhitespaces<param-value>true</param-value>
错误处理:Page directive has invalid attribute: trimDirectiveWhitespaces</init-param>查看JSP版本可以使用下面的命令:JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %>
更多信息可以参考:http://blog.csdn.net/xuhaiyang/archive/2008/05/23/2472591.aspx

?

热点排行