thymeleaf设置disabled

一、问题描述

在thymeleaf中如何根据条件设置是否禁用某个控制,用别的模板引擎,如FreeMarker这种,直接用个if判断,将disabled放在,条件里面,成立,则禁用,在thymeleaf中没有这种语法,只能通过th:的方式来设置。

二、解决方法

具体代码如下所示:

<input class="form-control" th:disabled="${data.status != 5}" type="text" name="status">

后台传个data对象,只要status属性不等于5则禁用该标签。

猜你喜欢

转载自blog.csdn.net/mashangzhifu/article/details/118341479