在如下调用时出错:
<jsp:include page="fastpost.jsp">
<jsp:param name="returl" value="<%=Url.encode(****) %>" />
</jsp:include>
这里,在 value 中只是使用了 URL 而已。
然后报错:
Attribute value Url.encode(****) is quoted with " which must be escaped when used within the value
啊,无语,在另一个页面中这么写就没错啊?
Google。
发现说是什么 apache 升级到 6.0 后出现的 bug。
详情见:
[#MMB-1706] quoted must be escaped - MMBase
然后跟踪链接,这里说的很详细了:
Possible user code changes required when we upgrade to Tomcat 6.0.18
按照上面的说法,这么改写:
<jsp:include page="fastpost.jsp">
<jsp:param name="returl" value='<%=Url.encode(****) %>' />
</jsp:include>
其实只是把 value="" 改成 value=''。
对于上面这个问题我分别用Tomcat5.5 安装版和 Tomcat6.0.2解压版测试了一下,果然在Tomcat6.0.2下面提示value后面要使用单引号。。
我想上面这个把双引号改成单引号的做法是不可接受的。因为我们的程序已经写好了,难道全部改成单引号?
再查GOOGLE,上面有人说使用Tomcat6.0的解压版不出错,而安装版会出现这个问题。。不过在我的测试中Tomcat6.0的解压版也是有问题的。。。所以再看
可以通过设置System Properties来改变tomcat的默认行为: org.apache.jasper.compiler. Parser.STRICT_QUOTE_ESCAPING If false the requirements for escpaing quotes in JSP attributes will be relaxed so that a missing required quote will not cause an error. If not specified, the specification compliant default of true will be used.打开网址:http://tomcat.apache.org/tomcat-5.5-doc/config/systemprops.html
可以看到,我们可以修改这个配置,即可解决这个问题
所以解决这个问题的最终办法是:
修改Tomcat目录:D:\Java\tomcat-6.0.20\conf下面的catalina.properties文件,在最后面加入:
org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false
即可。转自: http://quicker.iteye.com/blog/739779