简体   繁体   中英

How to place a variable value in string format of html text?

I have a requirement that I need to add a some values to the string format of html code which will be in sent to mail acts as unsubscribe link when I click on it it will go to some page. Here I have variable want to add is UrlVariable. this variable have already some value say for example organization. It has to append to the url. Lithe total url after appending variable value should be like this.

unsubscribe/asr/unsubscribe?type=organization.
   private String subscribeInfoContent = "<div style='margin-top:20px;'>
   <a href='sunny:8080/unsubscribe/asr/unsubscribe?type='unSubscribeUrlVariable'>
                Click here to unsubscribe from this newsletter.
   </a>
</div>";

只需将 + 运算符添加到字符串和变量即可。

private String subscribeInfoContent = "<div style=\"margin-top:20px;\"><a href=\"sunny:8080/unsubscribe/asr/unsubscribe?type="+unSubscribeUrlVariable+"\">Click here to unsubscribe from this newsletter.</a></div>";

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