这个可以用在很多地方,比如短信、邮件的消息。用法如下:public static void main(String[] args) { String info = "{0}您好,欢迎来到{1},\n记…
这个可以用在很多地方,比如短信、邮件的消息。
用法如下:
String pattern1 = "尊敬的 {0} 先生/女士 ,欢迎您预约贝壳找房平台看房,您的管家 {1} 手机号是 {2} 看房时间:{3} ,已经预约通过,请等待管家联系您";
String pattern2 = "At {3,time,short} on {3,date,long}";
Object[] params = {"hoonick","李明","55555555",new Date()};
//使用默认的本地化对象格式化字符串
String format = MessageFormat.format(pattern1, params);
System.out.println(format);
//使用指定的本地化对象格式化字符串
MessageFormat mf = new MessageFormat(pattern2, Locale.US);
String format2 = mf.format(params);
System.out.println(format2);
动态调用模板
String message=MessageFormat.format(hsMessageTemplate.getTemplateMessage(),hsHousekeepers.getHousekeeper());
String phone=appointmentVo.getAppointmentTelphone();
System.out.println(message);
SmsAli smsUtil = new SmsAli(); 调用短信配置文件发送短信
msUtil.smsUtil(phone,message);