问题描述:

I have been tasked with re-writing some HTML code that is used to display a link. I know that to display a link in HTML I can do something like this:

<a href="www.stackoverflow.com">Awesome Site!</a>

The only problem is that I am constructing this link with variables pulled from a bean. Here is an example:

<a href="http://<bean:message bundle='system' key='server.ip'/>/Application/list?variable=<%=variable%>"></a>

When generated this will be an actual working link. To take the easy way out I could simply add some text in between the tags like I did with the top example:

<a href="http://<bean:message bundle='system' key='server.ip'/>/Application/list?variable=<%=variable%>">CLICK ME!!!</a>

and when I click on the text (CLICK ME!!!) it would direct me to the link destination.

My only issue is that I don't want to add any text to click on. I want it to display the actual text that is generated from the construction of bean variables in the form of a link so that when I click on it, it will take me to my destination.

Does anyone have any ideas on how to accomplish this, or if it is even possible? Also, if you need further clarification please feel free to let me know and I can explain further.

Your assistance is greatly appreciated!

Thank you,

-Dave

网友答案:

So it seems that I can actually just take what is inside the href and insert it between the tags and it will display the actual link.

My worry was that it would not insert the variables and it would print the literal string that I was inserting. However it does seem to display the link as I intended. The complete code is as follows:

<td style="font-size: 14px; background-color: #f0f0f0;">
    <a href="http://<bean:message bundle='system' key='server.ip'/>/Application/list?listId=<%=listId%>&listSecurityString=<%=listSecurityString%>">
        http://<bean:message bundle='system' key='server.ip'/>/Application/list?listId=<%=listId%>&listSecurityString=<%=listSecurityString%>
    </a>
</td> 

Hopefully this will help someone else if they ever experience the same problem!

Have a good day and happy coding!

相关阅读:
Top