列出Thymeleaf中所有可用的模型属性 [英] List all available model attributes in Thymeleaf

查看:94
本文介绍了列出Thymeleaf中所有可用的模型属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于调试目的,我想列出thymeleaf模板在渲染时可用的所有模型属性.

For debugging purposes I would like to list all model attributes available to my thymeleaf template while it is rendering.

类似的东西:

<table>
    <tr th:each="model : ${*}">
        <td th:text="${model}"></td>
    </tr>
</table>

但是显然那是胡说八道,而且我得到了当之无愧的错误.( org.springframework.expression.spel.SpelParseException:EL1070E:(pos 0):解析左操作数时出现问题)

But obviously that's nonsense, and I get a well-deserved error. (org.springframework.expression.spel.SpelParseException: EL1070E:(pos 0): Problem parsing left operand)

是否有一种输出此类调试信息的方法?我什至会为一些日志输出感到满意.

Is there a way of outputting such debug information? I'd settle even for some logging output.

或者,Thymeleaf是否提供类似于Struts 2的 struts.devMode 的功能,它在页面底部添加了列出所有可用属性的调试部分?

Or, does Thymeleaf provide something similar to Struts 2's struts.devMode where it added a debug section at the bottom of the page listing all available properties?

推荐答案

尝试一下:

<table>
    <tr th:each="var : ${#vars}">
        <td th:text="${var.key}"></td>
        <td th:text="${var.value}"></td>
    </tr>
</table>

这篇关于列出Thymeleaf中所有可用的模型属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆