java - 我 thymeleaf 如何使用页面参数作为属性键?

标签 java spring-mvc spring-boot thymeleaf

Controller中有这样的重定向:

return "redirect:login?message=login.registered";

在 html 模板中,我想显示 login.registered 键的属性值。

在 jsp 中它只是:

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
...
<spring:message code="${param.message}"/>

如何使用 Thymeleaf 执行相同操作?

最佳答案

我认为在 thymeleaf 中,您可以使用 #messages 对象来做到这一点。这应该有效:

<div th:text="${#messages.msg(param.message)}" />

关于java - 我 thymeleaf 如何使用页面参数作为属性键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43939232/

相关文章:

java - DLL 到 LIB - 无法使用 JNI 和 System.load 调用打开 LIB 文件

java - 将变量声明为某种类型

java - 获取错误 java.lang.IllegalArgumentException : unexpected url

java - 从Java文件写入jsp文件

Java Spring启动: Reload config without spring cloud config server

java - 从hadoop中的作业conf获取输入路径

javascript - 如何使用 Angular JS 将数据保存到数据库中?

java - 为什么我得到 org.hibernate.MappingException : Could not instantiate id generator?

postgresql - 测试容器和错误 : "Failed to validate connection org.postgresql.jdbc.PgConnection" (raising a single container for all test classes)

spring-boot - Elasticsearch Resthighlevelclient 将数据索引到 AWS Elasticsearch 服务时出现 Noclassfound 错误