Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为什么Thymeleaf忽略了这个三元?_Html_Thymeleaf - Fatal编程技术网

Html 为什么Thymeleaf忽略了这个三元?

Html 为什么Thymeleaf忽略了这个三元?,html,thymeleaf,Html,Thymeleaf,这里是错误。我检查row.link是否为null,但它仍尝试计算表达式。当row.link不为null时,它会正确设置onclick属性。我还尝试在末尾添加:,以及:myattr=2,只是想看看它是否需要一些东西,这些东西是无法进行事件分析的 Here is the line th:attr="${row.link!=null} ? onclick=|rowClicked('${row.link.url()}', '${T

这里是错误。我检查row.link是否为null,但它仍尝试计算表达式。当row.link不为null时,它会正确设置onclick属性。我还尝试在末尾添加
,以及
:myattr=2
,只是想看看它是否需要一些东西,这些东西是无法进行事件分析的

Here is the line                                    

th:attr="${row.link!=null} ? onclick=|rowClicked('${row.link.url()}', '${T(java.util.Arrays).toString(row.link.params())}','${row.componentId}')|" >

如果
row.link
为空,该怎么办?什么都没有?你也能贴上完整的标签吗?如果row.link存在,则可能是一种更好的方法,它可以添加onclick属性,该属性调用名为rowClicked的javascript函数(url、参数、组件ID)。如果row.link为null,则不添加onclick属性。我已经能够用th:if th:except做if了,但这在将来是不可用的,因为将有具有类似条件的父元素,并且将需要大量的冗余复制粘贴,并且每个元素的文档大小将增加一倍
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "row.link.url()" (template: "fragments/table.html" - line 108, col 11)
...
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method url() on null context object