Playframework 2.0 将html格式应用于i18n消息

Playframework 2.0 将html格式应用于i18n消息,playframework-2.0,Playframework 2.0,在游戏中!2.0我们可以向i18n消息传递参数,如下所示: 在我看来:(message.key=task.created,带有参数:firstName和代码) × @消息(“task.created”,MyContext.currentUser().firstName,newTask.code) 我的信息定义为: task.created=<strong>{0}</strong>, your task has been saved with code {1} tas

在游戏中!2.0我们可以向i18n消息传递参数,如下所示:

在我看来:(message.key=task.created,带有参数:firstName和代码)


×
@消息(“task.created”,MyContext.currentUser().firstName,newTask.code)
我的信息定义为:

task.created=<strong>{0}</strong>, your task has been saved with code {1}
task.created={0},您的任务已与代码{1}一起保存
我希望看到带有HTML标记strong的
firstName
,但它不是应用strong标记,而是打印
strong
标记

我希望你能理解我的问题。这在游戏中可能吗

谢谢

这样做:

@Html(Messages("task.created", MyContext.currentUser().firstName, newTask.code))

我希望这能帮助你

如果用户的名字包含HTML,这是否会打开XSS漏洞?是的,使用@HTML会将任何内容呈现为HTML,因此提供给消息的任何参数都有XSS漏洞。
@Html(Messages("task.created", MyContext.currentUser().firstName, newTask.code))