Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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
从控制器返回的值的spring内部化_Spring_Spring Boot_Spring Mvc - Fatal编程技术网

从控制器返回的值的spring内部化

从控制器返回的值的spring内部化,spring,spring-boot,spring-mvc,Spring,Spring Boot,Spring Mvc,我已从控制器返回此消息,即 model.addAttribute("Message", "This is the English version of this website"); 当前,它已使用行显示 [[${Message}]] 将显示上述信息。如何使上述消息值内部化。因此,消息将更改为不同的语言 像这样的东西 th:text=“#{home.page.title}”>>将显示标题为多个lang 如何处理[${Message}]]多语言请按以下步骤尝试: 在messages.prope

我已从控制器返回此消息,即

model.addAttribute("Message", "This is the English version of this website");
当前,它已使用行显示

[[${Message}]]
将显示上述信息。如何使上述消息值内部化。因此,消息将更改为不同的语言

像这样的东西

th:text=“#{home.page.title}”>>将显示标题为多个lang


如何处理[${Message}]]多语言

请按以下步骤尝试:

  • messages.properties
    中:

    labels.my_label=这是本网站的英文版

  • 在控制器中:

    model.addAttribute(“Message”、“labels.my_label”)

  • 以html(Thymeleaf)格式显示:
    您可以发送消息的键,而不是消息:
    model.addAttribute(“消息”、“消息键”)
    。在html中,使用
    [[{{{Message}}}]
    获取i18ncontent@ken2009这不起作用字符串消息=“这是本网站的英文版”;model.addAttribute(“Message”,Message);感谢您的详细解释。它工作得很有魅力