如何在 freemarker / spring 消息中添加参数化消息

how to add parameterized message in freemarker / spring messages

我在 Spring 应用程序中使用 freemarker 作为视图渲染器。有什么方法可以参数化来自 spring.ftl 库的消息吗?

在 java 中,我们将使用消息源 getMessageSource("code.key", new String[]{"param1", "param2"}, null, null) 并插入字符串。

但是 spring.messageTextspring.message 似乎没有此选项。

我错过了什么吗?有没有办法模拟它?我知道我可以在控制器中添加,但所有其他消息都使用宏,这似乎是一些应该很容易的解决方法...

Freemarker 可以与任何标签库一起使用。 您是否尝试过将 Spring 标签库与 "message" 标签一起使用? (<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>)

请参阅以下链接了解更多详情: http://freemarker.org/docs/pgui_misc_servlet.html#autoid_56 http://www.mkyong.com/spring-mvc/spring-mvc-internationalization-example/

如果这工作正常,请告诉我们..