Java 模板变量替换——字符串替换器{}、${}、${}map

// 直接使用hutool工具类即可
// format("this is {} for {}", "a", "b") = this is a for b
StrFormatter.formatWith("aa ${}", "${}", "b")
// format("this is {} for {}", "{}", "a", "b") = this is a for b
StrFormatter.formatWith("aa {}", "b")
  
// format 格式化文本,使用 {
    
    varName} 占位<br>
// map = {
    
    a: "aValue", b: "bValue"} format("{a} and {b}", map) ---= aValue and bValue

猜你喜欢

转载自blog.csdn.net/qq_39517116/article/details/128611126
今日推荐