问题描述:
I have url that has been encoded by HTMLEntityCodec
class.使用<a href> to link a HTMLEntityEncoded String
Let's say the original url is https://www.example.com/aa/bb
编码后的字符串变为:https &#x3-a; &#x2f-; &#x2f-; WWW .例如. COM #x2f-; AA &#x2f-; BB
然后我试着用<a href>
, 使用JSP中编码的url,但我得到的始终是https://www.example.com/aa/https:/-;/-;www.example.com:4443/-;aa/-;bb
看起来像输入被视为一个相对的网址和域被追加。
有什么想法?
答
我不知道JSP,但我猜
encoder.decodeForHTML(str);
是你在找什么(HtmlEntityCodec的功能)。
在将链接插入到a-tag的href属性之前,您应该解码html编码的URL。
我发现那里的功能:Java Code Example。这对你有帮助吗?