我有一个Java String
,需要将其显示在邮件正文中。此消息后,我想添加一个HTML按钮。我该怎么办?
我的字符串:
String customerMessage = "Hi, We have received your request. Your account will be unblocked within 48 hours.
我要添加的内容是在2行换行符之后:
<a href="http://www.google.com" target="_parent">
<button>Click me !</button>
</a>
答案 0 :(得分:1)
您需要将HTML代码编写为字符串,并在字符串中添加<br>
以便进行分隔。像:
StringBuilder sb = new StringBuilder();
sb.append("Hi, We have received your request. Your account will be unblocked within 48 hours.");
sb.append("<br><br><a href=\"http://www.google.com\" target=\"_blank\"><button>Click me !</button></a>");