[英]How to display the contents of <td> in two different lines in Thymeleaf and Spring Boot?
我有一个基于Spring Boot
的应用程序,它以表格格式显示一些数据。
我想在两条不同的行上但在同一<td>
内显示一些值。 像这样的东西。
Mule: Down
TC: Down
服务器服务.java
public String getServerStatus(String kdn, String hostname, String serverType) {
String muleStatus = getMuleStatus(hostname, MULE_DEV_STATUS_SSH_CMD);
String tcStatus = getTCStatus(hostname);
serverStatus = muleStatus + "<br/>" + tcStatus;
return serverStatus;
}
从上面提到的服务 class 中,我改变了我的逻辑返回一个看起来像这样的String
: TC: Down <br/> Mule: Down
,希望浏览器会自动解析这个HTML
标签并将内容显示在两个不同的行在同一列中。 但这没有用。
因此,我在server.html
文件中添加了<td th:text="${#strings.escapeXml(appDeploy.server.status)}">001</td>
但这也没有帮助,在我看到的浏览器中像这样的东西。
Mule: DOWN<br/>TC: DOWN
不知道还缺少什么。
如果你的目的只是让它在 Thymeleaf 中分成两行,你应该将 th:text 更改为 th:utext。
<td th:text="${appDeploy.server.status}"></td>
像:
<td th:utext="${appDeploy.server.status}"></td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.