gpt4 book ai didi

Thymeleaf:使用命名空间设置属性

转载 作者:行者123 更新时间:2023-12-03 22:54:06 24 4
gpt4 key购买 nike

在 Spring Boot 应用程序中,我尝试设置一个带有命名空间的属性。这是我尝试过的:

<svg id="svg1" width="100%" viewBox="0 0 400 100" xmlns="http://www.w3.org/2000/svg"
xmlns:th="http://www.thymeleaf.org"
xmlns:xlink="http://www.w3.org/1999/xlink">
...
<image th:attr="x=${thumbx},xlink:href=${thumbfile}"
x="150" y="50" width="20" height="20"
xlink:href="http://s3.amazonaws.com/some.png"/>
...
</svg>

引发 org.thymeleaf.exceptions.TemplateProcessingException:无法解析为分配序列:“x=${thumbx},xlink:href=${thumbfile}”。

关于如何设置属性 xlink:href 的任何想法?

最佳答案

尝试用简单的引号将属性名括起来:

<image th:attr="x=${thumbx},'xlink:href'=${thumbfile}" />

关于Thymeleaf:使用命名空间设置属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35672993/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com