[英]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.