在如下調用時出錯: <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