我想在jsp中使用encodeURL
方法来编码带有“%”符号的URL。如何使用特殊字符“百分比”对URL进行编码?
response.encodeURL(/page1/page2/view.jsp?name=Population of 91% in this place)
每当按钮被点击,示出"The website cannot display the page"
错误。
但是,当您手动将"%"
符号更改为"%25"
(如“Population of 91%25 in this place
”)时,将显示正确的页面。
而且每当"%"
符号被放置在最后像这样的“In this place Population of 91%
”,那么页面显示正常,但我注意到,在地址栏中它仍显示为"%"
而不是"%25"
仍其工作。
当我四处搜寻,其只提到使用其他方法,如encodeURI() & encodeURIComponent().
能同时仍使用encodeURL
方法来正确显示页面,即使是有"%"
符号,你给我建议的解决方案。我应该使用replace()
或为什么不是encodeURL()
方法正常工作?