title: Bootstrap Navbar Highlighting in Thymeleaf's layout
body: <p>I am evaluating spring boot + MVC + bootstrap . One problem I am facing is bootstrap's navbar highlighting problem in thymeleaf.</p>
  
  <p>I hope thymeleaf can judge the tab which should be highlighted.</p>
  
  <p>I searched and found this solution : <a href="http://nixmash.com/java/bootstrap-navbar-highlighting-in-thymeleaf/" rel="nofollow">Bootstrap Navbar Highlighting in Thymeleaf</a></p>
  
  <p>In the containing(outer) page , it uses </p>
  
  <pre><code>&lt;div th:replace="header::header('home')"&gt;
    to be replaced header
  &lt;/div&gt;
  </code></pre>
  
  <p>to designate the <code>home</code> tab should be highlighted. </p>
  
  <p>And in the contained (inner) page , it uses</p>
  
  <pre><code>&lt;nav class="..." th:fragment="header(activeTab)"&gt;
  &lt;ul class="nav navbar-nav"&gt;
    &lt;li th:class="${activeTab == 'home'} ? 'active' : null "&gt;&lt;a href="#" th:href="@{/home}"&gt;Home&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>to judge this tab should be highlighted or not.</p>
  
  <p>It works for <strong>every single page</strong> well , <strong>but not for layout</strong>.</p>
  
  <p>In a layout page , the containing (outer) page is a decorator , which decorates other pages (home / about / contact ...) . The tab value is pending here .</p>
  
  <p>for example</p>
  
  <pre><code>&lt;div th:replace="header::header('home')"&gt;
    to be replaced header
  &lt;/div&gt;
  &lt;div layout:fragment="content"&gt;
    layout
  &lt;/div&gt;
  &lt;div th:replace="footer::footer"&gt;
    to be replaced footer
  &lt;/div&gt;
  </code></pre>
  
  <p>I cannot pre-assign <code>home</code> tab in the layout file.
  Is there any way to solve it ?</p>
  
  <p>Can it judge by controller or even controller's method ?</p>
  
  <p>environment : </p>
  
  <pre><code>springboot.version 1.3.0.M5
  spring.version :4.2.1.RELEASE 
  </code></pre>
  
  <p>Thanks a lot !</p>