简体   繁体   中英

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

您没有安装可以自动将电子邮件模式转换为链接的油脂猴子吗?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM