简体   繁体   English

在超链接文本中显示特殊字符

[英]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> . 我在Java类中使用了HTML,在一种情况下,我使用了<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. 在一种情况下,其值为'rg @ bg',但在这里不是名称,而是在我的jsp中获取它所指向的URL。 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 如果变量称为username并且打印了“用户名”而不是username的内容,则似乎您需要执行以下操作

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

instead of 代替

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

In jsp you could also simply write 在jsp中,您也可以简单地编写

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

If the problem concerns treatment of html-entities you may find the following interesting: 如果问题与html实体的处理有关,您可能会发现以下有趣的现象:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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