占位符替换函数
public static String replacePlaceHolder(String template, Map<String, String> models) {
if (template.indexOf("${") == -1) {
return template;
}
while (true) {
int start = template.indexOf("${");
int end = template.indexOf("}", start);
if (start != -1 && end != -1) {
String key = template.substring(start + 2, end);
if (models.containsKey(key)) {
template = template.substring(0, start) + models.get(key) + template.substring(end + 1);
}
} else {
break;
}
}
return template;
}