java - thymeleaf 中 String 对象的 #strings.replace() 实用方法是否替换了提供的字符串中的所有匹配项?

标签 java html spring-boot thymeleaf

我有一个字符串作为

str = My name is john.<br> I am software engineer.<br> I am a web developer<br>

我想替换所有出现的 <br><br />在 thymeleaf 中。

我试过了

${#strings.replace(str,'<br>','<br />')} 

我想知道,上面的字符串替换方法是否替换了所有出现的 <br>

引用资料:
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html
https://www.baeldung.com/spring-thymeleaf-3-expressions

最佳答案

是的,它将替换所有出现的地方。 Thymeleaf 在内部调用 java.lang.String.replace 方法来替换出现的位置。

关于java - thymeleaf 中 String 对象的 #strings.replace() 实用方法是否替换了提供的字符串中的所有匹配项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56768219/

相关文章:

javascript - 匹配父元素内的文本

javascript - jQuery:动画小数

Spring Boot 在 SpringApplication.run 之前检查属性

java - 使用Java实现字典

java - Neo4j 密码 MATCH 查询不起作用

java - Hibernate删除关系manyToMany

java - 为什么输出是这样的? ( java )

html - 对象标记内的段落

spring-boot - Gradle 5 JUnit BOM 和 Spring Boot 版本不正确

java - springboot线程数不断增加