久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

根據上下文數據顯示主動導航

Displaying active navigation based on contextual data(根據上下文數據顯示主動導航)
本文介紹了根據上下文數據顯示主動導航的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在 Thymeleaf 模板中有以下分離的片段.

I have the following separated fragment in a Thymeleaf template.

<ul class="nav nav-tabs">
    <li role="presentation"><a href="/">Freight Invoices</a></li>
    <li role="presentation"><a href="/processed">Processed Invoices</a></li>
    <li role="presentation"><a href="/postingrules">Posting Rules</a></li>
    <li role="presentation" class="active"><a href="/settings">Settings</a></li>
</ul>

我想為活動導航元素添加一個活動"類——但在 Thymyleaf 中似乎很難實現.有什么建議嗎?

I want to add an "active" class to active navigation element — but it seems hard to accomplish in Thymyleaf. Any suggestions?

推薦答案

您可以在控制器中為每個頁面添加一個 ModelAttribute,其值為 active,例如:

You could add a ModelAttribute with the value active in your controllers for each page, e.g. :

SettingsController.java

@RequestMapping("/settings")
public String viewSettings(Model model) {
  // do stuff
  model.addAttribute("classActiveSettings","active");
  return "settings";
}

OR 在 SettingsControllerAdvice.java

@ControllerAdvice(assignableTypes = SettingsController.class)
public class SettingsControllerAdvice {

    @ModelAttribute("classActiveSettings")
    public String cssActivePage() {
        return "active";
    }

}

然后,在您的 settings.html 中包含的導航片段中:

Then, in the navigation fragment included in your settings.html :

<ul class="nav nav-tabs">
     <!-- Other links -->
    <li role="presentation" th:class="${classActiveSettings}">
       <a th:href="@{/settings}">Settings</a>
    </li>
</ul>

最后,您可以對導航欄中的每個控制器和鏈接重復此過程.

Finally, you can repeat this process for each controller and links in your navbar.

這篇關于根據上下文數據顯示主動導航的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Upload progress listener not fired (Google drive API)(上傳進度偵聽器未觸發(Google 驅動器 API))
Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 將文件保存在特定文件夾中)
Google Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 無效的 DriveId 和 Null ResourceId)
Google drive api services account view uploaded files to google drive using java(谷歌驅動api服務賬戶查看上傳文件到谷歌驅動使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務帳號返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例中缺少)
主站蜘蛛池模板: 欧美性受xxxx白人性爽 | 欧美精三区欧美精三区 | 欧美日韩国产中文 | 欧美中文字幕在线观看 | 久久精品亚洲欧美日韩精品中文字幕 | 免费日韩av| 国产一区亚洲 | 97人人澡人人爽91综合色 | 天堂在线中文 | 欧美性极品xxxx做受 | 久久久婷 | 亚洲欧美一区二区在线观看 | 中文字幕国产视频 | 男人的天堂在线视频 | 国产日韩欧美一区 | 欧美一级观看 | 日韩中文字幕在线观看 | 成年视频在线观看福利资源 | 欧美在线日韩 | 性色在线 | 污片在线免费观看 | 三级成人在线观看 | 久久国产精品网站 | 看片91| 黄色国产大片 | 91免费在线看 | 99精品久久 | 欧美一二三四成人免费视频 | 国产区视频在线观看 | 操一草| 久久99国产精品 | 国产乱码精品一区二区三区五月婷 | 亚洲一区二区精品视频在线观看 | 亚洲午夜电影 | 中文字幕亚洲一区二区va在线 | 亚洲三区在线观看 | 精品久久一区二区三区 | 黄色免费网址大全 | 欧美日本在线观看 | 国产一区二区久久久 | 中文字幕日韩在线 |