Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.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
Html Thymeleaf:访问环境bean_Html_Css_Spring_Spring Boot_Thymeleaf - Fatal编程技术网

Html Thymeleaf:访问环境bean

Html Thymeleaf:访问环境bean,html,css,spring,spring-boot,thymeleaf,Html,Css,Spring,Spring Boot,Thymeleaf,我想访问环境属性: <h1 th:text="${@environment.getProperty('site.name1')}"> <span th:text="${@environment.getProperty('site.name2')}"></span> </h1>

我想访问环境属性:

<h1 th:text="${@environment.getProperty('site.name1')}">
                                    <span th:text="${@environment.getProperty('site.name2')}"></span>
                                </h1>
这是使用以下工具时的外观:

<h1>Plats
<span class="muellerhoff">Bruts</span>
</h1>
Plats
畜生

以及:

    <h1>
<span th:text="${@environment.getProperty('site.name1')}"></span>
                                        <br/>
<span class="muellerhoff"  th:text="${@environment.getProperty('site.name2')}"></span>
</h1>



最终目标如下:

Plats
畜生
在这种情况下,您可以使用
来处理
name1
值。块标记不会出现在最终的HTML中



可以找到有关
th:block
标记的更多信息。

对于site.name1来说没问题,但是对于site.name2(?!)来说没问题。您的
标记中有内容-在本例中,是
标记。
标记中的所有内容都将被H1的
th:text
值的结果替换。这就是
name2
值消失的原因。整个
标记将被删除。我已经撤回了我的重复投票-这与此无关-对此表示抱歉。在这些情况下,我想从最终结果开始:你需要最终的HTML是什么样的?然后,您可以从中反向创建相关的Thymeleaf。
    <h1>
<span th:text="${@environment.getProperty('site.name1')}"></span>
                                        <br/>
<span class="muellerhoff"  th:text="${@environment.getProperty('site.name2')}"></span>
</h1>