Pergunta

I can easily navigate the second link but when I try to navigate first link, I'm directed to the wrong url. Here is the code:

StringBuilder footerBuffer = new StringBuilder();
footerBuffer.append("<b>Init:</b> http://127.0.0.1:8080/ABC/init/library?bookId=173&auth=1568&delta=yes <br/>");
footerBuffer.append("<b>Home:</b> https://127.0.0.1:8443/ABC <br/>");
footer.setText(Html.fromHtml(footerBuffer.toString()));

The url that I'm directed for the first url is:

http://127.0.0.1:8080/ABC/init/library?bookId=173&auth=1568%CE%B4=yes

I see %CE%B4 in spite of &delta. What could be the problem?

Foi útil?

Solução

Because &delta; is character reference name for δ, see http://www.whatwg.org/specs/web-apps/current-work/multipage/named-character-references.html#entity-delta.

You should escape characters with Html.escapeHtml() or whatever. Html.escapeHtml() requires API level 16 or above. If you want to work on lower API level, see Apache Commons Lang.

https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringEscapeUtils.html

Outras dicas

&delta; is a HTML special character (like &amp; and so on) - I believe that &delta is converted to the url encoding of the delta character. You could try using %26 (which is the url-encoded value of &) instead of the ampersand for the delta parameter.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top