使用JavaSpringMVC+Thymeleaf更新网页元素而不刷新
我正在构建一个webapp,用于监视一系列传感器节点的状态&;通过COAP协议执行机构。当我得到一个新的读数(如温度变化)时,我想更新网页上的相应数据
在网页上,我有一个包含所有节点信息的表,每行一个节点。 理想情况下,我希望“获取”对应节点的表行,并使用新的值更改温度值
我无法在Spring控制器中找到这样做的方法
这是HTML Thymeleaf表:
<table style="display: inline-block" id="actuatorTable" border="1px solid black">
<thead style="font-weight:bold;">
<tr>
<th>NAME</th>
<th>IP</th>
<th>TYPE</th>
<th>RESOURCE</th>
<th>VALUE</th>
<th></th>
</tr>
</thead>
<tbody>
<tr th:each="actuator: ${actuators}">
<td th:utext="${actuator.nodeName}"></td>
<td th:utext="${actuator.nodeIP}"></td>
<td th:utext="${actuator.nodeType}"></td>
<td th:utext="${actuator.nodeResource}"></td>
<td th:utext="${actuator.currentValue}"></td>
<td><button th:nodeIP="${actuator.nodeIP}" onclick="changeStatus(this.getAttribute('nodeIP'), 'on')">ON</button></td>
<td><button th:nodeIP="${actuator.nodeIP}" onclick="changeStatus(this.getAttribute('nodeIP'), 'off')">OFF</button></td>
</tr>
</tbody>
</table>
共 (0) 个答案