有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

javajquery+thymeleaf

我无法从thymeleaf中的交换机获取数据

我是这样做的,对于没有开关的正常数据,它可以工作:

<tr>
    <td>Zatrudniony</td>
    <td th:attr="id='datewo' + ${employee.empEvidenceNumber}">
        <span th:text="${employee.empFirstWorkDay}"></span>
    </td>
</tr>

和my jQuery以显示我可以在模式输入字段中显示的此行数据:

var empDepartmentId = $('#dep' + empEvidenceNumber).text();
$("#empDepartmentId").val(empDepartmentId);

但此jQuery代码不显示来自thymeleaf开关的数据:

<tr>
    <td>Jest kierownikiem</td>
    <td th:attr="id='isman' + ${employee.empEvidenceNumber}">
        <div th:switch="${employee.empIsManager}">
            <span th:case="1" th:text="tak"></span>
            <span th:case="*" th:text="nie"></span>
        </div>
    </td>
</tr>

我试图在div和span组件中设置这个id属性,但仍然没有设置。 我怎么做


共 (1) 个答案

  1. # 1 楼答案

    <tr>
        <td>Jest kierownikiem</td>
        <td th:attr="id='isman' + ${employee.empEvidenceNumber}">
            <th:block th:switch="${employee.empIsManager}">
                <div th:case="1">
                    <span th:text="tak"></span> 
                </div>
                <div th:case="*">
                    <span th:case="*" th:text="nie"></span>
                </div>
            </th:block>
        </td>
    </tr>