【发布时间】:2012-01-03 13:45:36
【问题描述】:
我正在尝试在 jsp 中使用 encodeURL 方法对带有“%”符号的 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() 方法不能正常工作?
【问题讨论】: