简体   繁体   中英

How can i show two values of data from database in html?

I expect to join the year and the month the output like this in the table "2019-5" The others doing fine, organizer, and workshop shows its data, the only problem is the year and the month i wanted to show.

 <tbody id="idTbodyWorkshop"> <tr th:each="item : ${keyworkshop}"> <td th:text="${item.training_name}">Workshop</td> <td th:text="${item.organizer}">Organizer</td> <td th:text="${item.training_year}" th:text="${item.training_month}">Date /*This is the 2 values i mentioned*/</td> <td th:text="${item.training_duration}">Duration</td> <td> <div class="dropdown"> <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"> More <span class="caret"></span> </button> <ul class="dropdown-menu"> <li class="clDropdown" data-value="0"><a href="#">edit</a></li> <li class="clDropdown" data-value="1"><a href="#">delete</a></li> </ul> </div> </td> </tr> </tbody> 

Try this:

th:text="${item.training_year item.training_month}"

it should work

您需要在单个th:text属性中提供与-串联的两个值,如下所示:

<td th:text="${item.training_year + '-' + item.training_month}">Date</td>

您可以将变量的作用域放在${} ,对于常量内容,请使用Colon('')。

${item.training_year + '-' + item.training_month}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM