Thymeleaf模板化th:data = http://www.somesite.com || org.thymeleaf.exceptions.TemplateProcessingException:无法解析为分配序列

问题描述 投票:0回答:2

这里是模板。

从TemplateEngine运行过程函数后,收到此错误org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as assignation sequence: "data=http://www.somesite.com" (template: "someFile.html" - line 5, col 2)

我尝试了几种不同的方法,并保持相同的结果。

<div class="someClass" th:id="${divId}">
    <object class="someClass" type="application/pdf" 
    th:data="'|${url}|'">
        <p>You don't have a PDF plugin for this browser.
                    <a th:href="@{|${url}|}">
                        Click here to download PDF file.
                    </a>
                </p>
        </object>
</div>

java spring-mvc jsp thymeleaf templating
2个回答
0
投票

您打算将string传递给th:当它期望expression时。

更改此:

th:data="'|${url}|'"

为此:

th:data=${url}

记住要更改也作为字符串的其他元素。


0
投票

您不需要大多数|字符(因为使用文字替换在这里没有什么区别。您发布的代码应如下所示:

<div class="someClass" th:id="${divId}">
    <object class="someClass" type="application/pdf" th:data="${url}">
        <p>
            You don't have a PDF plugin for this browser.
            <a th:href="${url}">Click here to download PDF file.</a>
        </p>
    </object>
</div>

话虽这么说,您指示的错误通常是错误地使用th:with引起的,并且由于我在您提供给我们的代码中看不到任何地方,所以我怀疑您是否已找到问题的根本原因。] >

© www.soinside.com 2019 - 2024. All rights reserved.