Tomcat升級到6.0遇到的雙引號改單引號問題

來源:互聯網
上載者:User
在如下調用時出錯: <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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.