我的属性文件下有这个键值对
mailsubject = REDEX Application --- Credentials
mailtext = Dear User,\n \
Following Are the credentials for REDEX Mapping Application -- pwd
setFrom = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6018181813535120070d01090c4e030f0d" rel="noreferrer noopener nofollow">[email protected]</a>
这是我在 java 文件中使用它们通过 java 发送电子邮件的地方
try {
Message message = new MimeMessage(session);
message.setSubject(props_load.getProperty("mailsubject"));
message.setText(props_load.getProperty("mailtext") + " " +generatedpwd);
Transport.send(message);
result = "success";
} catch (MessagingException e) {
result = "fail";
logger.error("Exception Occured"+ "sendemalto" +sendemalto , e);
}
我的问题是,
是否可以在单词后插入用户名,使其看起来像
尊敬的用户 Kiran, 以下是 REDEX map 应用程序的凭据
最佳答案
如何定义占位符并将其替换为您的用户名:
props_load.getProperty("mailtext").replace("{{username}}", username)
你的模板是这样的:
mailtext = Dear User {{username}},\n ...
关于java - 如何在java中的某个单词后追加一个单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31651408/