开发者

displaying special characters in hyperlink text

I have used HTML in my Java class and in one case I have used <a href="...">username</a>. Username is a variable that gets values dynamically. In one case its value is 'rg@bg' but here instead of the name I'm getting the URL to which it is directed in my jsp. How do I ensure that the value of username开发者_如何学编程 comes on the display page as it is. I have tried "@"+username. Didn't work


You don't have greasemonkey installed which automatically converts email patterns into links?


I'm not sure I understand your problem, but here is a guess.

I suspect you do the actual print wrong. If the variable is called username and "username" is printed instead of the content of username it seems you need to do something like

print("<a href=\"...\">" + username + "</a>");

instead of

print("<a href=\"...\">username</a>");

In jsp you could also simply write

<a href="..."><%= username %></a>

If the problem concerns treatment of html-entities you may find the following interesting:

http://www.rgagnon.com/javadetails/java-0306.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜