字符串替换 StrSubstitutor

依赖jar包

<dependency>
    <groupId>org.apache.commonsgroupId>
    <artifactId>commons-lang3artifactId>
    <version>3.7version>
dependency>

示例

public static void main(String[] args) {        
        Map map = new HashMap();
        map.put("code","267468");
        map.put("product","xxx系统");
        String str1 = "您正在登录${product},验证码为:${code},五分钟内有效,如非本人操作请忽略。";
        StrSubstitutor sb = new StrSubstitutor(map);
        String content = sb.replace(str1);
        System.out.println(content);
}

你可能感兴趣的:(1024程序员节)