thymeleaf 动态更换内容( Error resolving template xxx, template might not exist or might not be ......)

thymeleaf 动态更换内容(Error resolving template xxx, template might not exist or might not be ......

错误解决的方法

 th:replace="__${page_area}__"

加双下划线,是预处理表达式

序言

今天我用thymeleaf的时候需要实现一个功能,就是用th:fragment,th:replace实现后台传其值的动态更换内容。
比如这一句本来固定这样替换的:

   <div th:replace="managment/index">
                内容区域
   </div>

我用变量替换了那个文本:

 <div th:replace="${page_area}">
                内容区域
 </div>

想要后台控制替换的值,但是报错了

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [management/index::content], template might not exist or might not be accessible by any of the configured Template Resolvers (template: “common/frame” - line 131, col 18)

我翻了中文文档都没有找到解决方法,可能很少有人这么用吧,但是我在官方文档中有这样一句:
在这里插入图片描述
大概的意思就是:预处理表达式和普通的表达式一样,但是被两个双划线符号所包围,就像__${express0ion}__

然后我就将其改变为:

 <div th:replace="__${page_area}__">
                内容区域
 </div>

然后就可以了

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值