Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.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条件元素内呈现_Html_Thymeleaf - Fatal编程技术网

HTML元素未在Thymeleaf条件元素内呈现

HTML元素未在Thymeleaf条件元素内呈现,html,thymeleaf,Html,Thymeleaf,这是我第一次使用thymeleaf,如果用户输入了错误的凭据,我将使用Spring将flash属性返回到登录页面。 显示错误消息(2div),但不呈现内部的 源代码 &时代; 消息右侧应该有一个“x”。我打开了浏览器检查器,但它也没有显示在HTML中 浏览器检查器代码 用户名/密码不正确。 ::之后 基本上×被th:text=“${message}”覆盖。解决方案是使用th:utext并添加&次以及错误消息。 i、 e.在属性文件中定义属性,如view.error=不正确的用户

这是我第一次使用thymeleaf,如果用户输入了错误的凭据,我将使用Spring将flash属性返回到登录页面。 显示错误消息(2
div
),但不呈现内部的

源代码


&时代;
消息右侧应该有一个“x”。我打开了浏览器检查器,但它也没有显示在HTML中

浏览器检查器代码


用户名/密码不正确。
::之后
基本上
×
th:text=“${message}”
覆盖。解决方案是使用
th:utext
并添加
&次以及错误消息。

i、 e.在属性文件中定义属性,如
view.error=不正确的用户名/密码&时代
像这样使用它

<div th:text="#{view.error}" th:class="${'col s8 offset-s2 m6 offset-m3 alert ' + alertClass}"></div>

希望这会有所帮助。

我还添加了配置类,并将
messages.properties
放在我的资源文件夹的根目录中,这就解决了它。
<div class="row">
    <div class="col s8 offset-s2 m6 offset-m3 alert error">Incorrect username / password.</div>
    ::after
</div>
<div th:text="#{view.error}" th:class="${'col s8 offset-s2 m6 offset-m3 alert ' + alertClass}"></div>