胸腺循环在具有对象列表属性问题的对象列表上
我正在春季靴子上工作,胸腺呈现不同的桌子的桌子呈现问题。首先必须是一个字符串,后续行必须是保存在对象列表中的数据。
问题的情况:
我有一个对象列表,此对象具有两个属性,一个是字符串列表,另一个是不同对象的列表。我不知道如何在表中的胸腺中渲染一行中字符串列表的第一个属性,以及该表的下一行呈现属性对象的第二个列表。
该对象的详细信息:
public class objetosDeServiciosAD {
private String Servicio;
private LinkedList<usuarioAD> listaUsuariosAD;
public String getServicio() {
return Servicio;
}
public void setServicio(String servicio) {
Servicio = servicio;
}
public LinkedList<usuarioAD> getListaUsuariosAD() {
return listaUsuariosAD;
}
public void setListaUsuariosAD(LinkedList<usuarioAD> listaUsuariosAD) {
this.listaUsuariosAD = listaUsuariosAD;
}
@Override
public String toString() {
return "objetosDeServiciosAD [Servicio=" + Servicio + ", listaUsuariosAD=" + listaUsuariosAD + "]";
}
}
objetos_servicios是一个具有两个侵犯的对象的列表,一个是Servicio 该对象具有第二个Attibute,它是对象列表,这是Listausuariosad。
这是我在胸腺中的代码:
<table class="table table-hover">
<thead class="thead-light">
<tr>
<th scope="col">Usuario</th>
<th scope="col">Teléfono</th>
<th scope="col">mail</th>
<th scope="col">Descripción</th>
</tr>
</thead>
<tbody>
<tr th:each="servicio : ${objetos_Servicios}">
<td th:text="${servicio.servicio}"></td>
<tr th:each=" listaeusuario : ${servicio.listaUsuariosAD}">
<tr th:each ="usuarios : ${listaeusuario}">
<td th:text = "${usuarios.usuario}"></td>
<td th:text = "${usuarios.telefono}"></td>
<td th:text = "${usuarios.mail}"></td>
<td th:text = "${usuarios.descripion}"></td>
</tr>
</tr>
</tbody>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该代码将看起来像这样:
您可以使用
th:block
标签在较大的代码块上循环(其中包含标题&lt; tr/&gt;
和行&lt; tr /&gt; < /code>)。
The code will look something like this:
You can use a
th:block
tag to loop over a larger block of code (that contains the header<tr />
and the rows<tr />
).我建议更改您正在使用的命名标准,以便所有类名称都以上案字母开头 - 例如:
objetosdesviciosad
而不是objetosdesviciosad
。这是Java中的标准配置 - 对于其他阅读您的代码的人来说,不这样做可能会使您感到困惑。因此,您的类变为:
我还用
list 替换了
linkedlist
,因为您似乎在此处需要链接列表(如果您实际上这样做,则可以恢复更改) 。然后,对于胸腺模板,您可以使用百里叶的 标记要构造迭代循环:
在上面的代码中,我还替换了
$ {servicio.getListausuarioSad()}
simpler$ {servicio.listausuariosad}
,由于您无需明确调用该方法,因此。我还添加了三个空的
&lt; td&gt;/td&gt;
单元格以确保每行完成,用于显示servicio
text的行。I recommend changing the naming standards you are using, so that all your class names begin with an upper-case letter - for example:
ObjetosDeServiciosAD
instead ofobjetosDeServiciosAD
. This is standard in Java - and not doing this can be confusing for other people who read your code.So, your class becomes:
I also replaced
LinkedList
withList
, since you do not appear to need a linked list here (if you actually do, you can revert that change).Then, for your Thymeleaf template, you can use Thymeleaf's
<th:block>
tag to structure your iteration loops:In the above code, I also replaced
${servicio.getListaUsuariosAD()}
with the simpler${servicio.listaUsuariosAD}
, since you do not need to explicitly call the method, here.I also added three empty
<td></td>
cells to ensure each row is complete, for the row displaying theservicio
text.