skip to Main Content

I would like to add data from my controller to present a progressbar in thymeleaf. I tried different approaches but none work.

<div class="progress progress-striped">
    <div class="progress-bar progress-bar-warning" role="progressbar" **th:aria-valuenow="${model}"** aria-valuemin="0" aria-valuemax="100" **th:style="@{'width:'+ ${percent} +';'}"**>
         <span class="sr-only">30% Complete (warning)</span>
     </div>

2

Answers


  1. Chosen as BEST ANSWER

    Found it :

    <div class="progress progress-striped">
    <div class="progress-bar progress-bar-warning" role="progressbar" **th:aria-valuenow="${model}"** aria-valuemin="0" aria-valuemax="100" th:attr="aria-valuenow=${model}" th:style="'width:'+ ${percent}+';'}">
         <span class="sr-only">30% Complete (warning)</span>
     </div>
    

  2. I tried using your answer and it didn’t worked for me, but it helped to find an answer for me:

    <div class="progress active">
        <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar"  aria-valuemin="0" aria-valuemax="100" th:attr="aria-valuenow=${p.value}" th:style="'width:'+ ${p.percent}+'%;'"></div>
    </div>
    

    p.value and p.percent are model attributes that I send from my controller. Both have numeric values.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search