如何在HTML中设置@modelattribute布尔值 [英] how to set @modelattribute boolean value inside html

查看:416
本文介绍了如何在HTML中设置@modelattribute布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码如下所示

@Modelattribute中的用户"值是布尔值,说明如何设置此条件

the Users value from @Modelattribute is boolean an how to set this condition

 <div  th:each="s: ${Users}"> 
        <div  th:if="${s == true"  >
            <header th:include="../templates/SellerTemplate :: header" id="header">
            </header>
        </div>
        <div th:if="${s != true}" >
            <header  th:include="../templates/homeTemplate :: header" id="header">
            </header> 
        </div> 

    </div>

@Model属性

public boolean users ;
@ModelAttribute("Users")
public boolean getloggeduser() {
 if(securityDAO.getLoggedUserAccount()!= null) { 
    users=true;
     }
 else{ 
     users=false;
 } 
    return users;
}

主要问题是如何将属性值设置为th:每个或任何其他可用的语句?请分享您的答案

the main problem is how to set the attribute value to th:each or any other statement are available? please share your answer

推荐答案

我相信您正在寻找这样的东西:

I believe that you are looking for something like this:

<div th:if="${Users == true}"  >
   <header th:include="../templates/SellerTemplate :: header" id="header">
   </header>
</div>
<div th:if="${Users == false}" >
   <header  th:include="../templates/homeTemplate :: header" id="header">
   </header> 
</div> 

您只能将th:each用于列表或数组,没有意义将其用于其他类型.

You should only use th:each for lists or arrays, there is no point using it for other types.

这篇关于如何在HTML中设置@modelattribute布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆