Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.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 Thymeleaf不接受th:include中的本地化_Spring_Spring Mvc_Internationalization_Thymeleaf - Fatal编程技术网

Spring Thymeleaf不接受th:include中的本地化

Spring Thymeleaf不接受th:include中的本地化,spring,spring-mvc,internationalization,thymeleaf,Spring,Spring Mvc,Internationalization,Thymeleaf,我试图将Spring的本地化包与Thymeleaf模板一起使用。如果在普通模板中使用它,它工作得很好,但如果在容器标记处应用th:include属性,它就会失败 我将视图代码放在Gist中: 有问题的本地化在第4行和第10行。在第10行中,我看到了正确的扩展(“新机器”),但在第4行中,我只得到“null”作为页面标题 你能告诉我我做错了什么吗 With th:include您正在用从片段中获取的内容替换内部内容,即标题标记。由于您没有发布头部片段模板,我无法为您提供更多关于该模板的提示。我怀疑

我试图将Spring的本地化包与Thymeleaf模板一起使用。如果在普通模板中使用它,它工作得很好,但如果在容器标记处应用th:include属性,它就会失败

我将视图代码放在Gist中:

有问题的本地化在第4行和第10行。在第10行中,我看到了正确的扩展(“新机器”),但在第4行中,我只得到“null”作为页面标题


你能告诉我我做错了什么吗

With th:include您正在用从片段中获取的内容替换内部内容,即标题标记。由于您没有发布头部片段模板,我无法为您提供更多关于该模板的提示。我怀疑你头部片段中的标题标签对标题标签做了一些不同的事情?

正如马丁所说,你的th:include正在替换你的标题标签,你应该这样做:

<head>
    <title th:text="#{page.title.machine.new}">&nbsp;</title>
    <dif th:include="widgets/_head :: head" th:remove="tag"></dif>
</head>

th:remove=“tag”将删除dif标记


Thymeleaf网站有一些有用的功能。

我想,th:include混合了这两个内容,因为有一个th:replace用于替换,但我不确定。。。标题片段不包含标题标记。奇怪的是,我在响应html中有标题标签,只是本地化没有扩展。我用一个新链接更新了问题,其中包含主视图和包含的模板。