我想用 thymeleaf 解析一个 html,然后得到结果并在其上做一些我自己的其他过程。我怎样才能做到这一点?
它是这样的:在我的 Controller 中,我向我的模型添加属性,thymeleaf 根据这些属性解析 html 文件,如下面的代码
<span th:text="${foo.name}"></span>
然后结果将是这样的,并作为用户的响应发送
<span>Sample Name</span>
例如,我希望在发送结果之前让用户对其进行更多手动编辑。
最佳答案
我想,您想对名称进行手动编辑。 在创建 foo 对象的类中创建方法。 例如
public class Foo {
private String name;
public String getModifyName(){
// Implement here what you want to do.
// For example
return "Mr. " + name;
}
}
然后在 html 中使用 <span th:text="${foo.modifyName}"> </span>
关于java - 如何获得 thymeleaf 解析器的结果(html)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25521097/