I have the following separated fragment in a Thymeleaf template.
-
May be this code would be helpful for someone. Attention! It's not Thymeleaf solution, just js code which you can add on your pages.
var currentPage = location.href.match(/(.*?)([^\/]+)$/).pop();
$(Array.prototype.filter.call($('.menu-head li a:nth-child(1)'), function(item)
{
return item.href.endsWith(currentPage)
})).parents('li').addClass('active');