首页
IT
登录
6mi
u
盘
搜
搜 索
IT
thymeleaf 获取map的值
thymeleaf 获取map的值
xiaoxiao
2021-03-26
23
个人测试的表单验证的返回,使用errorMap存放错误信息
<
form
class
=
"form-signin"
action
=
"/login"
method
=
"POST"
>
<!--<p th:each="attr : ${#request.getAttributeNames()}"-->
<!--th:text="${attr} +':'+${#request.getAttribute(attr)}"> 如果你想知道request中有什么属性</p>-->
<
p
th:text
=
"${#request.getAttribute('errorMap')}"
>
errorMap中有什么属性
</
p
>
<
input
type
=
"text"
name
=
"username"
class
=
"form-control"
placeholder
=
"用户名"
autofocus
th:class
=
"'field-error form-control'"
th:value
=
"${usernameInput}"
>
<
label
class
=
"error-label"
th:if
=
"${errorMap}"
th:text
=
"${errorMap['username']}"
>
</
label
>
<
input
type
=
"password"
name
=
"password"
class
=
"form-control"
placeholder
=
"密码"
th:class
=
"'field-error form-control'"
th:value
=
"${passwordInput}"
>
<
label
class
=
"error-label"
th:if
=
"${errorMap}"
th:text
=
"${errorMap['password']}"
>
</
label
>
<
input
type
=
"text"
name
=
"validateCode"
class
=
"form-control"
placeholder
=
"验证码"
th:class
=
"'field-error'"
>
<
img
src
=
"/validateCode"
>
<
label
class
=
"error-label"
th:if
=
"${errorMap}"
th:text
=
"${errorMap['validateCodeError']}"
>
</
label
>
<
button
class
=
"btn btn-lg btn-login btn-block"
type
=
"submit"
>
<
i
class
=
"fa fa-check"
>
</
i
>
</
button
>
</
form
>
示例结果:
转载请注明原文地址: https://ju.6miu.com/read-660504.html
技术
最新回复
(
0
)