我有一个包含网址的变量。
String url = getEnvironment().getProperty(CUSTOMER_SIGN_IN_PAGE_URL);
所以我如何使用此url变量作为以下代码段的url
String customerMessage = new StringBuilder("Hi, We have received your request. Your account will be unblocked within 48 hours.")
.append("<br><br><a href=\" url \" target=\"_blank\"><button> CONTINUE </button></a>")
.toString();
答案 0 :(得分:0)
您需要使用第二个“”转义字符串,并使用+
连接它例如
String customerMessage = new StringBuilder("Hi, We have received your request. Your account will be unblocked within 48 hours.")
.append("<br><br><a href=\""+ url +"\" target=\"_blank\"><button> CONTINUE </button></a>")
.toString();
实际上,如果您想实现基于服务器的解决方案,则应该看一下Java Server Pages(JSP)或Java Server Faces(JSF)。
答案 1 :(得分:0)
我喜欢使用String.format()
:
String customerMessage = String.format("Hi, We have received your request. Your account will be unblocked within 48 hours.\n<br><br><a href=\"%s\" target=\"_blank\"><button> CONTINUE </button></a>", url);