简体   繁体   English

Thymeleaf:解析表达式时出错

[英]Thymeleaf: Error parsing expression

I have a Thymeleaf template with this code for pagination 我有一个带有此代码的Thymeleaf模板以进行分页

<ul class="results_perpage"  >
                                    <li th:if="${previous != null}"><a th:href="javascript:movePage(`${previous}`);" class="results_menu" th:text="PREVIOUS"></a></li>
                                    <li><a href="#"           class="results_menu" th:text="${numPage}"></a></li>
                                    <li><a th:href="javascript:movePage(`${next}`);"  class="results_menu" th:text="NEXT"></a></li>
                                </ul>

But I have this error 但是我有这个错误

Could not parse as expression: "javascript:movePage('${previous}');" 

I also tried with the grave ascent(`) with the same result 我也尝试了严重的ascent(`),结果相同

You need to use thymeleaf syntax to add context variables 您需要使用thymeleaf语法添加上下文变量

th:href="'movePage(\'' + ${previous} + '\');'"

Actually I think you should use onClick in place of href. 实际上,我认为您应该使用onClick代替href。

th:onclick="'movePage(\'' + ${previous} + '\');'"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM